#4351

feat(notifications): node-local notif.written hook

Openjfcastro92wants to merge intofrom

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.written fires once per recipient for every non-silent write (notify) and for rewrites in place (notifyUpdate, with updated: true). Payload: { userId, uid, type, appUid?, value, updated? }.
  • Typed in EventMap and 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.written hands 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 carries appUid from the row.

Tests

  • NotificationService.test.ts gains three cases: one event per recipient with the payload, none for a silent write, and updated: true on a rewrite.
  • Notification service, driver and events registry tests: 147 passed. Typecheck: no new errors.

Activity

6
github-actions[bot]4d ago

Coverage Report

StatusCategoryPercentageCovered / Total
🔵Lines95.04%
⬆️ +0.02 pp
39362 / 41415
🔵Statements93.22%
⬆️ +0.02 pp
43239 / 46380
🔵Functions92.59%
⬆️ +0.01 pp
7442 / 8037
🔵Branches84.58%
⬆️ +0.04 pp
30286 / 35807
File Coverage
FileStmtsBranchesFunctionsLinesUncovered Lines
Changed Files
src/backend/clients/event/types.ts100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
src/backend/services/events/registry.ts100%
🟰 ±0 pp
93.75%
🟰 ±0 pp
100%
🟰 ±0 pp
100%
🟰 ±0 pp
src/backend/services/notification/NotificationService.ts92.1%
⬆️ +0.29 pp
89.28%
⬇️ -1.10 pp
80.76%
🟰 ±0 pp
92.63%
⬆️ +0.33 pp
45-48, 153, 254-257, 297-298
Generated in workflow #3053 for commit 5970051 by the Vitest Coverage Report Action