diff options
author | David Baker <dave@matrix.org> | 2016-04-07 15:39:53 +0100 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2016-04-07 15:39:53 +0100 |
commit | 92e3071623c34350bf072bb77e089d5d6d5f41c2 (patch) | |
tree | cfed2957e7294260313c7c1997dd54f852402772 /synapse/handlers/receipts.py | |
parent | pep8 (diff) | |
download | synapse-92e3071623c34350bf072bb77e089d5d6d5f41c2.tar.xz |
Send badge count pushes.
Also fix bugs with retrying.
Diffstat (limited to 'synapse/handlers/receipts.py')
-rw-r--r-- | synapse/handlers/receipts.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/synapse/handlers/receipts.py b/synapse/handlers/receipts.py index 935c339707..26b0368080 100644 --- a/synapse/handlers/receipts.py +++ b/synapse/handlers/receipts.py @@ -80,6 +80,9 @@ class ReceiptsHandler(BaseHandler): def _handle_new_receipts(self, receipts): """Takes a list of receipts, stores them and informs the notifier. """ + min_batch_id = None + max_batch_id = None + for receipt in receipts: room_id = receipt["room_id"] receipt_type = receipt["receipt_type"] @@ -97,10 +100,20 @@ class ReceiptsHandler(BaseHandler): stream_id, max_persisted_id = res - with PreserveLoggingContext(): - self.notifier.on_new_event( - "receipt_key", max_persisted_id, rooms=[room_id] - ) + if min_batch_id is None or stream_id < min_batch_id: + min_batch_id = stream_id + if max_batch_id is None or max_persisted_id > max_batch_id: + max_batch_id = max_persisted_id + + affected_room_ids = list(set([r["room_id"] for r in receipts])) + + with PreserveLoggingContext(): + self.notifier.on_new_event( + "receipt_key", max_batch_id, rooms=affected_room_ids + ) + self.hs.get_pusherpool().on_new_receipts( + min_batch_id, max_batch_id, affected_room_ids + ) defer.returnValue(True) |