feat(phase-18): add in-app notification system (T-128, T-129)

This commit is contained in:
2026-02-09 13:52:04 +01:00
parent cda59de426
commit fb7f340038
16 changed files with 7577 additions and 2 deletions

View File

@@ -17,6 +17,7 @@ from apscheduler.schedulers.background import BackgroundScheduler
from app.database import SessionLocal
from app.services.mitre_sync_service import sync_mitre
from app.services.intel_service import scan_intel
from app.services.notification_service import cleanup_old_notifications
logger = logging.getLogger(__name__)
@@ -45,6 +46,19 @@ def _run_mitre_sync() -> None:
db.close()
def _run_notification_cleanup() -> None:
"""Clean up old read notifications."""
logger.info("Scheduled notification cleanup job starting...")
db = SessionLocal()
try:
deleted = cleanup_old_notifications(db, days=90)
logger.info("Notification cleanup finished — deleted %d old notifications", deleted)
except Exception:
logger.exception("Notification cleanup job failed")
finally:
db.close()
def _run_intel_scan() -> None:
"""Execute an intel scan inside its own DB session."""
logger.info("Scheduled intel scan job starting...")
@@ -89,5 +103,13 @@ def start_scheduler() -> None:
name="Intel scan (every 7d)",
replace_existing=True,
)
scheduler.add_job(
_run_notification_cleanup,
trigger="interval",
hours=24,
id="notification_cleanup",
name="Notification cleanup (daily)",
replace_existing=True,
)
scheduler.start()
logger.info("Background scheduler started — mitre_sync (24h), intel_scan (7d)")
logger.info("Background scheduler started — mitre_sync (24h), intel_scan (7d), notification_cleanup (24h)")