#4351
feat(notifications): node-local notif.written hook
NotificationService emits a node-local notif.written event after it writes a notification, so an extension can act on new notifications without core knowing what it does. Part of PUT-2167. Stacks on #4317.
What
notif.writtenfires once per recipient for every non-silent write (notify) and for rewrites in place (notifyUpdate, withupdated: true). Payload:{ userId, uid, type, appUid?, value, updated? }.- Typed in
EventMapand listed under the unpublished internal events in the events registry, so apps can't subscribe to it. - Silent writes don't emit.
Review follow-ups
notif.writtenhands each listener its own copy of the payload, so a listener changing it can't change what the desktop receives.- The payload now carries
audience, and the update emit carriesappUidfrom the row.
Tests
NotificationService.test.tsgains three cases: one event per recipient with the payload, none for a silent write, andupdated: trueon a rewrite.- Notification service, driver and events registry tests: 147 passed. Typecheck: no new errors.
Coverage Report
⬆️ +0.02 pp
⬆️ +0.02 pp
⬆️ +0.01 pp
⬆️ +0.04 pp
File Coverage
🟰 ±0 pp
🟰 ±0 pp
🟰 ±0 pp
🟰 ±0 pp
🟰 ±0 pp
🟰 ±0 pp
🟰 ±0 pp
🟰 ±0 pp
⬆️ +0.29 pp
⬇️ -1.10 pp
🟰 ±0 pp
⬆️ +0.33 pp