feat(ntfy): Phase 2 — sendPushToUsers() ntfy 연동 + 구독 관리 UI
- ntfy_subscriptions 테이블 마이그레이션 추가 - ntfySender.js 유틸 (ntfy HTTP POST 래퍼) - sendPushToUsers() ntfy 우선 분기 (ntfy 구독자 → ntfy, 나머지 → Web Push) - ntfy subscribe/unsubscribe/status API 엔드포인트 - notification-bell.js ntfy 토글 버튼 + 앱 설정 안내 모달 - docker-compose system1-api에 NTFY 환경변수 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,64 @@ const pushSubscriptionController = {
|
||||
console.error('Push 구독 해제 오류:', error);
|
||||
res.status(500).json({ success: false, message: 'Push 구독 해제 중 오류가 발생했습니다.' });
|
||||
}
|
||||
},
|
||||
|
||||
// === ntfy ===
|
||||
|
||||
// ntfy 구독 등록
|
||||
async ntfySubscribe(req, res) {
|
||||
try {
|
||||
const userId = req.user?.id;
|
||||
await pushSubscriptionModel.ntfySubscribe(userId);
|
||||
|
||||
const topic = `tkfactory-user-${userId}`;
|
||||
res.json({
|
||||
success: true,
|
||||
message: 'ntfy 구독이 등록되었습니다.',
|
||||
data: {
|
||||
topic,
|
||||
serverUrl: process.env.NTFY_EXTERNAL_URL || 'https://ntfy.technicalkorea.net',
|
||||
username: 'subscriber',
|
||||
password: 'tkfactory-sub-2026'
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('ntfy 구독 오류:', error);
|
||||
res.status(500).json({ success: false, message: 'ntfy 구독 중 오류가 발생했습니다.' });
|
||||
}
|
||||
},
|
||||
|
||||
// ntfy 구독 해제
|
||||
async ntfyUnsubscribe(req, res) {
|
||||
try {
|
||||
const userId = req.user?.id;
|
||||
await pushSubscriptionModel.ntfyUnsubscribe(userId);
|
||||
res.json({ success: true, message: 'ntfy 구독이 해제되었습니다.' });
|
||||
} catch (error) {
|
||||
console.error('ntfy 구독 해제 오류:', error);
|
||||
res.status(500).json({ success: false, message: 'ntfy 구독 해제 중 오류가 발생했습니다.' });
|
||||
}
|
||||
},
|
||||
|
||||
// ntfy 구독 상태 확인
|
||||
async ntfyStatus(req, res) {
|
||||
try {
|
||||
const userId = req.user?.id;
|
||||
const subscribed = await pushSubscriptionModel.isNtfySubscribed(userId);
|
||||
const topic = `tkfactory-user-${userId}`;
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
data: {
|
||||
subscribed,
|
||||
topic,
|
||||
serverUrl: process.env.NTFY_EXTERNAL_URL || 'https://ntfy.technicalkorea.net'
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('ntfy 상태 확인 오류:', error);
|
||||
res.status(500).json({ success: false, message: 'ntfy 상태 확인 중 오류가 발생했습니다.' });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user