feat(backend): platform notifications service with audiences, dedupe, read state and first producers
Platform v2 step 1.11 (APPS_PLATFORM section 10).
- notifications + notification_reads (revision 0010). Text = i18n key notification.<key> + params,
rendered in the reader's language (en, el added).
- core/notifications.py: notify(key, severity, audience, params, dedupe_key, ttl/expires_at, fold)
never raises; audience all_managers | perm:<key> | user:<id>; a live duplicate only bumps
count/last_at (no unread reset, no event). New ones emit WS platform_notification {id} to the
audience's users (current apps ignore it; phase 2 manager shows it).
- API (core, /api/platform/notifications; /api/notifications is chat's): list with unread count,
POST /{id}/read, POST /read-all.
- Producers: license.limit_reached (device pairing/reassign/over-limit device, per module/limit/day,
owners), license.expiring (14/7/3/1 days, from apply_license, owners), support.access_used (each
use, core.settings.manage), print.failed_final (abandoned retry job, per printer/hour, managers).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -230,7 +230,9 @@ def support_verify(body: SupportVerifyRequest, request: Request, db: Session = D
|
||||
row.session_id = session.id
|
||||
db.commit()
|
||||
_logger.warning("support.access_used challenge=%s sid=%s ip=%s", row.id, session.id[:8], session.ip)
|
||||
# >>> step 1.11: notify owners (support.access_used)
|
||||
from core.notifications import notify
|
||||
notify("support.access_used", "warning", "perm:core.settings.manage", {"ip": session.ip or "?"},
|
||||
dedupe_key=f"support.access_used:{row.id}", db=db)
|
||||
return TokenResponse(access_token=make_token(support, session.id, hours=SUPPORT_SESSION_HOURS),
|
||||
user=UserOut.model_validate(support))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user