feat: 실시간 알림 시스템 (Web Push + 알림 벨 + 서비스간 알림 연동)
- Phase 1: 모든 서비스 헤더에 알림 벨 UI 추가 (notification-bell.js) - Phase 2: VAPID Web Push 구독/전송 (push-sw.js, pushSubscription API) - Phase 3: 내부 알림 API + notifyHelper로 서비스간 알림 연동 - tksafety: 출입 승인/반려, 안전교육 완료, 방문자 체크인 - tkpurchase: 일용공 신청, 작업보고서 제출 - system2-report: 신고 접수/확인/처리완료 - Phase 4: 30일 이상 알림 자동 정리 cron, Redis 캐싱 - CORS에 tkuser/tkpurchase/tksafety 서브도메인 추가 - HTML cache busting 버전 갱신 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -120,4 +120,21 @@ process.on('uncaughtException', (error) => {
|
||||
}
|
||||
})();
|
||||
|
||||
// 오래된 알림 정리 cron (매일 03:00 KST)
|
||||
(function scheduleNotificationCleanup() {
|
||||
const notificationModel = require('./models/notificationModel');
|
||||
function runCleanup() {
|
||||
const now = new Date();
|
||||
const kstHour = (now.getUTCHours() + 9) % 24;
|
||||
if (kstHour === 3 && now.getMinutes() < 1) {
|
||||
notificationModel.deleteOld(30).then(count => {
|
||||
if (count > 0) logger.info(`오래된 알림 ${count}건 정리 완료`);
|
||||
}).catch(err => {
|
||||
logger.error('알림 정리 실패:', { error: err.message });
|
||||
});
|
||||
}
|
||||
}
|
||||
setInterval(runCleanup, 60000); // 1분마다 확인
|
||||
})();
|
||||
|
||||
module.exports = app;
|
||||
|
||||
Reference in New Issue
Block a user