feat(project): silence web alert popup while PC notifier is running

If the user has a non-revoked notifier token seen in the last 3 minutes,
/api/notifications/alerts returns only the baseline with desktop=true;
the web marks it seen so alerts resume on the web after the app stops.
A failing check keeps the web popup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 11:35:14 +09:00
parent 4715de9b5b
commit 84113d1fd7
6 changed files with 62 additions and 4 deletions
+13
View File
@@ -2299,9 +2299,22 @@ def api_notification_alerts(request: Request, after: int = -1) -> JSONResponse:
처음 쓰는 브라우저가 쌓인 옛 알림을 한꺼번에 띄우지 않게."""
user = _require_user(request)
st = _db_or_503(request)
# PC 알림 프로그램이 돌고 있으면(023, 최근 3분 안에 확인) 웹 팝업은 띄우지 않는다 — 기준점(latest_id)만 주고
# desktop=True. 웹은 그 번호까지 본 것으로 두어, 프로그램을 끄면 그 뒤에 온 알림부터 다시 웹에 뜬다.
if _notifier_active(st, user):
out = _alerts_payload(st, user, -1)
out["desktop"] = True
return JSONResponse(out)
return JSONResponse(_alerts_payload(st, user, after))
def _notifier_active(st: Any, user: dict[str, Any]) -> bool:
try:
return bool(st.notifier_active(email=user["email"]))
except Exception: # noqa: BLE001 — 확인 실패면 웹 팝업을 그대로(알림을 놓치지 않게)
return False
def _alerts_payload(st: Any, user: dict[str, Any], after: int) -> dict[str, Any]:
"""큰 팝업 알림 — 웹 화면(initTaskAlerts)과 PC 알림 프로그램이 같이 쓴다."""
newest = st.list_notifications(recipient_email=user["email"], limit=1)