Skip to content

Implement notifications, pushers and key backup - #1

Merged
Fizzadar merged 8 commits into
mainfrom
nick/add-notification-counts
Oct 3, 2026
Merged

Fizzadar merged 8 commits into
mainfrom
nick/add-notification-counts

Conversation

@Fizzadar

Copy link
Copy Markdown
Contributor

No description provided.

@Fizzadar Fizzadar self-assigned this Jan 14, 2026
@Fizzadar
Fizzadar marked this pull request as draft January 14, 2026 18:22
@Fizzadar Fizzadar removed their assignment Jan 14, 2026
@Fizzadar
Fizzadar force-pushed the nick/add-notification-counts branch from 03c1bd6 to c459bfb Compare January 16, 2026 22:18
@beeper beeper deleted a comment from coderabbitai Bot Jan 16, 2026
@Fizzadar
Fizzadar force-pushed the nick/add-notification-counts branch 3 times, most recently from f8fb22b to 699ca8f Compare January 26, 2026 18:09
@Fizzadar Fizzadar changed the title WIP: Implement notification counts Implement notification counts Jan 28, 2026
@Fizzadar
Fizzadar marked this pull request as ready for review January 28, 2026 20:22
@beeper beeper deleted a comment from coderabbitai Bot Jan 28, 2026
coderabbitai[bot]

This comment was marked as low quality.

coderabbitai[bot]

This comment was marked as low quality.

@Fizzadar Fizzadar changed the title Implement notification counts Implement notifications, pushers and key backup Sep 12, 2026
@beeper beeper deleted a comment from coderabbitai Bot Sep 12, 2026
@Fizzadar
Fizzadar force-pushed the nick/add-notification-counts branch 2 times, most recently from 2da1a88 to 63667e3 Compare September 12, 2026 20:14
@indent

indent Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
PR Summary

Adds three Matrix feature areas to the babbleserv (FoundationDB) homeserver: per-event notification counts with thread support, push rules + evaluation + pushers + push-gateway sending, and key backup APIs. Also removes the per-database Enabled config flags (Rooms/Accounts/Transient are now always initialized; deployment is gated by top-level RoutesEnabled/WorkersEnabled), refactors the notifier to deliver the full Change object to subscribers, and bumps Go to 1.27.

  • Notification counts stored as msgpack deltas per event version, summed on /sync (with per-thread counts via MSC3773), cleared on read receipts, and compacted by a background iterator; room member counts are now maintained incrementally to feed push-rule conditions.
  • Push rules stored in a new accounts directory, evaluated during event send, and delivered to clients as m.push_rules account data on sync; pushers stored per user with new /pushers endpoints.
  • New PushNotificationIterator sends pushes to each user's pushers for notifying events; CompactNotificationIterator trims old notification entries.
  • Key backup versions/keys implemented with count + etag metadata and the full /room_keys/* endpoint set.

Issues

All clear! No issues remaining. 🎉

8 issues already resolved
  • The push-gateway counts.unread is set to notifCount + highlightCount, but highlighted events already contribute to notifCount, so the push badge is inflated by the number of highlighted messages. (fixed by commit 116c03e)
  • getThreadRootID walks m.thread relations with no cycle/depth guard, so a stored self-referencing or cyclic thread relation (reachable via federation) loops forever inside the event-send write transaction, wedging the room and burning CPU. (fixed by commit 116c03e)
  • Once a room crosses MaxNotificationsPerUserRoom, roomIDToCount is never reset to 0, so compaction runs on every subsequent event in that room, and roomIDToCount/roomIDToCancel entries are never removed. (fixed by commit 03c1d1e)
  • Pushers are keyed by (userID, pushKey), but the Matrix spec identifies a pusher by the (app_id, pushkey) pair, so two pushers sharing a pushkey with different app_ids collide and overwrite each other. (fixed by commit 116c03e)
  • PutPushRule ignores the before/after query params and the storage keys rules by ruleId, so user rules are returned in lexical order appended after defaults and cannot be reordered, producing wrong push-rule evaluation order. (fixed by commit f5c2dee)
  • DELETE of a predefined .m.rule.* rule with no user override returns 200, bumps the push-rules version, and emits a spurious m.push_rules sync, while the rule remains present; the spec requires 404 and server defaults cannot be deleted. (fixed by commit f5c2dee)
  • PutPushRule does not reject ruleIds starting with '.' (reserved for server defaults) or containing '/' or '', so a client can shadow a predefined rule and cause GET to report it with default:false. (fixed by commit f5c2dee)
  • Errors from sendPushNotificationsForEvents are logged but ignored, and the stored iterator position is advanced past the batch anyway, so a transient DB error permanently skips push notifications for those events. (fixed by commit 116c03e)

CI Checks

All CI checks passed on ea91220.

Comment thread internal/workers/pushnotificationiterator.go Outdated
Comment thread internal/databases/rooms/notifications.go Outdated
Comment thread internal/workers/compactnotificationiterator.go
Comment thread internal/databases/accounts/users/pushers.go
Comment thread internal/routes/client/pushrules.go
Comment thread internal/routes/client/pushrules.go Outdated
Comment thread internal/routes/client/pushrules.go
Comment thread internal/workers/pushnotificationiterator.go
Support for notification counting over sync with threaded/unthreaded
receipts. Limitations:

- no push rules (yet), fixed rule eval (message = notif, m.mention = highlight)
- compaction of notification keys implemented, but disabled
	- individual notification keys are required for accurate counts as receipts move
	- in future we can compact versions >X old, accepting loss of accuracy
This handles the expansion of device IDs from "*" for to-device events
destined for local users and simplifies all the calls.
There's no real use-case for running these subsets of functionality
and it's increasing complexity as a result. Multiple workers is designed
to function without needing such config.
Adds all the CSAPI push rules endpoints, sync updates and evaluation
when counting room notifications. Limitations:

- no actual pushes yet (need pushers APIs)
- unoptimized push rule fetch for many users
- no display name matching yet
This means we get type safety on the channels, and can get room IDs from
all events subscriptions.
@Fizzadar
Fizzadar force-pushed the nick/add-notification-counts branch from e4d92e1 to ea91220 Compare September 30, 2026 21:24
@Fizzadar
Fizzadar merged commit ea91220 into main Oct 3, 2026
3 checks passed
@Fizzadar
Fizzadar deleted the nick/add-notification-counts branch October 3, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant