From f0ca08828082eb1f0a5214b14099034ca53ecbab Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 18 Oct 2016 10:52:47 +0100 Subject: [PATCH 1/2] Reduce redundant database work in email pusher Update the last stream ordering if the `get_unread_push_actions_for_user_in_range_for_email` returns no new push actions. This reduces the range that it needs to check next iteration. --- synapse/push/emailpusher.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/synapse/push/emailpusher.py b/synapse/push/emailpusher.py index 6600c9cd5..2eb325c7c 100644 --- a/synapse/push/emailpusher.py +++ b/synapse/push/emailpusher.py @@ -150,6 +150,10 @@ class EmailPusher(object): soonest_due_at = None + if not unprocessed: + yield self.save_last_stream_ordering_and_success(self.max_stream_ordering) + return + for push_action in unprocessed: received_at = push_action['received_ts'] if received_at is None: From 8ca05b57550d8d480a1b8cc5a25a6fffb9b09aa9 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 18 Oct 2016 10:57:33 +0100 Subject: [PATCH 2/2] Fix push notifications for a single unread message --- synapse/push/mailer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/push/mailer.py b/synapse/push/mailer.py index 3b63c19ec..53551632b 100644 --- a/synapse/push/mailer.py +++ b/synapse/push/mailer.py @@ -372,7 +372,7 @@ class Mailer(object): state_event_id = room_state_ids[room_id][ ("m.room.member", event.sender) ] - state_event = yield self.get_event(state_event_id) + state_event = yield self.store.get_event(state_event_id) sender_name = name_from_member_event(state_event) if sender_name is not None and room_name is not None: