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
+14
View File
@@ -1657,6 +1657,20 @@ class ProjectStore:
).fetchone()
return row["email"] if row else None
def notifier_active(self, *, email: str, within_sec: int = 180) -> bool:
"""이 사용자의 PC 알림 프로그램이 지금 돌고 있나 — 해제 안 된 토큰 중 최근(기본 3분) 확인한 것이 있으면 True.
프로그램은 20초마다 확인하고 last_seen_at 은 1분에 한 번 갱신되므로 3분이면 꺼진 PC 는 곧 빠진다. 023 미적용이면 False."""
try:
with self._pool.connection() as conn:
row = conn.execute(
"SELECT 1 FROM notifier_tokens WHERE email = %s AND revoked_at IS NULL "
"AND last_seen_at > now() - make_interval(secs => %s) LIMIT 1",
(store.norm_str(email, lower=True), within_sec),
).fetchone()
except psycopg_errors.UndefinedTable:
return False
return row is not None
def notifier_revoke_token(self, *, token: str) -> None:
with self._pool.connection() as conn:
conn.execute("UPDATE notifier_tokens SET revoked_at = now() WHERE token_hash = %s AND revoked_at IS NULL",