summary refs log tree commit diff
path: root/synapse/storage/receipts.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-05-13 14:41:36 +0100
committerErik Johnston <erik@matrix.org>2016-05-13 14:41:36 +0100
commite00e8f21660c021a4d93edd9531102ba1d5440e9 (patch)
tree3879bca04f72c0dc2d62b467595db63a4f9fab1b /synapse/storage/receipts.py
parentMerge pull request #779 from matrix-org/erikj/receipts (diff)
parentMerge branch 'develop' of github.com:matrix-org/synapse into erikj/push_actio... (diff)
downloadsynapse-e00e8f21660c021a4d93edd9531102ba1d5440e9.tar.xz
Merge pull request #769 from matrix-org/erikj/push_actions_delete
Delete old pushers
Diffstat (limited to 'synapse/storage/receipts.py')
-rw-r--r--synapse/storage/receipts.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/synapse/storage/receipts.py b/synapse/storage/receipts.py
index 669fc8ada2..94be820f86 100644
--- a/synapse/storage/receipts.py
+++ b/synapse/storage/receipts.py
@@ -244,6 +244,15 @@ class ReceiptsStore(SQLBaseStore):
             (user_id, room_id, receipt_type)
         )
 
+        res = self._simple_select_one_txn(
+            txn,
+            table="events",
+            retcols=["topological_ordering", "stream_ordering"],
+            keyvalues={"event_id": event_id},
+        )
+        topological_ordering = int(res["topological_ordering"])
+        stream_ordering = int(res["stream_ordering"])
+
         # We don't want to clobber receipts for more recent events, so we
         # have to compare orderings of existing receipts
         sql = (
@@ -256,15 +265,6 @@ class ReceiptsStore(SQLBaseStore):
         results = txn.fetchall()
 
         if results:
-            res = self._simple_select_one_txn(
-                txn,
-                table="events",
-                retcols=["topological_ordering", "stream_ordering"],
-                keyvalues={"event_id": event_id},
-            )
-            topological_ordering = int(res["topological_ordering"])
-            stream_ordering = int(res["stream_ordering"])
-
             for to, so, _ in results:
                 if int(to) > topological_ordering:
                     return False
@@ -294,6 +294,14 @@ class ReceiptsStore(SQLBaseStore):
             }
         )
 
+        if receipt_type == "m.read":
+            self._remove_push_actions_before_txn(
+                txn,
+                room_id=room_id,
+                user_id=user_id,
+                topological_ordering=topological_ordering,
+            )
+
         return True
 
     @defer.inlineCallbacks