anonymousland-synapse/synapse/storage
Matthew Hodgson 2292dc35fc Add experimental "dont_push" push action to suppress push for notifications
This is a potential solution to https://github.com/vector-im/riot-web/issues/3374
and https://github.com/vector-im/riot-web/issues/5953
as raised by Mozilla at https://github.com/vector-im/riot-web/issues/10868.

This lets you define a push rule action which increases the badge count (unread notification)
count on a given room, but doesn't actually send a push for that notification via email or HTTP.
We might want to define this as the default behaviour for group chats in future
to solve https://github.com/vector-im/riot-web/issues/3268 at last.

This is implemented as a string action rather than a tweak because:
 * Other pushers don't care about the tweak, given they won't ever get pushed
 * The DB can store the tweak more efficiently using the existing `notify` table.
 * It avoids breaking the default_notif/highlight_action optimisations.

Clients which generate their own notifs (e.g. desktop notifs from Riot/Web
would need to be aware of the new push action) to uphold it.

An alternative way to do this would be to maintain a `msg_count` alongside
`highlight_count` and `notification_count` in `unread_notifications` in sync responses.
However, doing this by counting the rows in `events` since the `stream_position`
of the user's last read receipt turns out to be painfully slow (~200ms), perhaps
due to the size of the events table.  So instead, we use the highly optimised
existing event_push_actions (and event_push_actions_staging) table to maintain
the counts - using the code paths which already exist for tracking unread
notification counts efficiently.  These queries are typically ~3ms or so.

The biggest issues I see here are:
 * We're slightly repurposing the `notif` field on `event_push_actions` to
   track whether a given action actually sent a `push` or not.  This doesn't
   seem unreasonable, but it's slightly naughty given that previously the
   field explicitly tracked whether `notify` was true for the action (and
   as a result, it was uselessly always set to 1 in the DB).
 * We're going to put more load on the `event_push_actions` table for all the
   random group chats which people had previously muted. In practice i don't
   think there are many of these though.
 * There isn't an MSC for this yet (although this comment could become one).
2019-09-19 00:54:05 +01:00
..
engines Run Black. (#5482) 2019-06-20 19:32:02 +10:00
schema Add 'failure_ts' column to 'destinations' table (#6016) 2019-09-17 11:41:54 +01:00
util Remove unnecessary parentheses around return statements (#5931) 2019-08-30 16:28:26 +01:00
__init__.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
_base.py Fix a cache-invalidation bug for worker-based deployments (#5920) 2019-08-28 10:18:16 +01:00
account_data.py Remove unnecessary parentheses around return statements (#5931) 2019-08-30 16:28:26 +01:00
appservice.py Remove double return statements (#5962) 2019-09-03 11:42:45 +01:00
background_updates.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
client_ips.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
deviceinbox.py Opentrace device lists (#5853) 2019-09-03 10:21:30 +01:00
devices.py Opentracing context cannot be none 2019-09-05 15:06:13 +01:00
directory.py Remove double return statements (#5962) 2019-09-03 11:42:45 +01:00
e2e_room_keys.py Opentrace e2e keys (#5855) 2019-08-22 11:28:12 +01:00
end_to_end_keys.py Opentrace e2e keys (#5855) 2019-08-22 11:28:12 +01:00
event_federation.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
event_push_actions.py Add experimental "dont_push" push action to suppress push for notifications 2019-09-19 00:54:05 +01:00
events_bg_updates.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
events_worker.py Handle loops in redaction events 2019-07-30 00:00:34 +01:00
events.py Fix comments 2019-09-09 15:08:24 +01:00
filtering.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
group_server.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
keys.py Run Black. (#5482) 2019-06-20 19:32:02 +10:00
media_repository.py Run Black. (#5482) 2019-06-20 19:32:02 +10:00
monthly_active_users.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
openid.py Run black on the rest of the storage module (#4996) 2019-04-03 10:07:29 +01:00
prepare_database.py Code style (Black) 2019-08-27 09:39:11 +01:00
presence.py Remove unnecessary parentheses around return statements (#5931) 2019-08-30 16:28:26 +01:00
profile.py Remove double return statements (#5962) 2019-09-03 11:42:45 +01:00
push_rule.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
pusher.py Remove unnecessary parentheses around return statements (#5931) 2019-08-30 16:28:26 +01:00
receipts.py Remove unnecessary parentheses around return statements (#5931) 2019-08-30 16:28:26 +01:00
registration.py Fix code style, again 2019-09-09 17:10:02 +03:00
rejections.py Run black on the rest of the storage module (#4996) 2019-04-03 10:07:29 +01:00
relations.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
room.py Drop some unused tables. (#5893) 2019-08-21 13:16:28 +01:00
roommember.py Servers-known-about statistic (#5981) 2019-09-07 01:45:51 +10:00
search.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
signatures.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
state_deltas.py Room Statistics (#4338) 2019-05-21 11:36:50 -05:00
state.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
stats.py Correctly handle non-bool m.federate flag 2019-09-06 14:21:06 +01:00
stream.py Remove unnecessary parentheses around return statements (#5931) 2019-08-30 16:28:26 +01:00
tags.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
transactions.py Add 'failure_ts' column to 'destinations' table (#6016) 2019-09-17 11:41:54 +01:00
user_directory.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00
user_erasure_store.py Replace returnValue with return (#5736) 2019-07-23 23:00:55 +10:00