This repository has been archived by the owner on Mar 26, 2024. It is now read-only.
forked from matrix-org/synapse
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Beeper user notification counts (#50)
* Implement notification count table insert and aggregate * Add Beeper notification count table migration * Appease sqlite * Fix aggregation query * Add experimental flag to enable user notification counts * More explicit column name * Offset recent notification counts by 100k most recent events Super arbitrary but this only exists as a temporary change, idea here is that the very latest counts are much more likely to be cleared by live receipts and we want to minimize serialization retries on the receipt transaction. * Don't allow local users to send receipts for unknown events This isn't firing in production but now must be checked to prevent issues with notification counts. * Clear notification counts on receipt * Fix starting value insert in migration * Use real rooms/events in receipt tests
- Loading branch information
Showing
7 changed files
with
207 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
synapse/storage/schema/main/delta/73/99_beeper_user_notification_counts.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CREATE TABLE beeper_user_notification_counts ( | ||
user_id TEXT, | ||
room_id TEXT, | ||
thread_id TEXT, | ||
event_stream_ordering BIGINT, | ||
notifs BIGINT, | ||
unreads BIGINT, | ||
highlights BIGINT, | ||
aggregated BOOLEAN, | ||
UNIQUE (user_id, room_id, thread_id, event_stream_ordering) | ||
); | ||
|
||
CREATE TABLE beeper_user_notification_counts_stream_ordering ( | ||
lock CHAR(1) NOT NULL DEFAULT 'X' UNIQUE, -- Makes sure this table only has one row. | ||
event_stream_ordering BIGINT NOT NULL, | ||
CHECK (lock='X') | ||
); | ||
|
||
INSERT INTO beeper_user_notification_counts_stream_ordering (event_stream_ordering) VALUES (0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters