summary refs log tree commit diff
path: root/synapse/storage/stream.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-09-23 15:28:32 +0100
committerErik Johnston <erik@matrix.org>2014-09-23 15:28:32 +0100
commit78af6bbb981c41e5509c99454deb7205c31bf964 (patch)
tree50dcd73e748b2807e22752f59bb940dd420078cb /synapse/storage/stream.py
parentAdd a deletions table (diff)
downloadsynapse-78af6bbb981c41e5509c99454deb7205c31bf964.tar.xz
Add m.room.deletion. If an event is deleted it will be returned to clients 'pruned', i.e. all client specified keys will be removed.
Diffstat (limited to 'synapse/storage/stream.py')
-rw-r--r--synapse/storage/stream.py30
1 files changed, 25 insertions, 5 deletions
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py
index a76fecf24f..aaac0aae30 100644
--- a/synapse/storage/stream.py
+++ b/synapse/storage/stream.py
@@ -157,6 +157,10 @@ class StreamStore(SQLBaseStore):
             "WHERE m.user_id = ? "
         )
 
+        del_sql = (
+            "SELECT event_id FROM deletions WHERE deletes = e.event_id"
+        )
+
         if limit:
             limit = max(limit, MAX_STREAM_SIZE)
         else:
@@ -171,13 +175,14 @@ class StreamStore(SQLBaseStore):
             return
 
         sql = (
-            "SELECT * FROM events as e WHERE "
+            "SELECT *, (%(deleted)s) AS deleted FROM events AS e WHERE "
             "((room_id IN (%(current)s)) OR "
             "(event_id IN (%(invites)s))) "
             "AND e.stream_ordering > ? AND e.stream_ordering <= ? "
             "AND e.outlier = 0 "
             "ORDER BY stream_ordering ASC LIMIT %(limit)d "
         ) % {
+            "deleted": del_sql,
             "current": current_room_membership_sql,
             "invites": membership_sql,
             "limit": limit
@@ -224,11 +229,20 @@ class StreamStore(SQLBaseStore):
         else:
             limit_str = ""
 
+        del_sql = (
+            "SELECT event_id FROM deletions WHERE deletes = events.event_id"
+        )
+
         sql = (
-            "SELECT * FROM events "
+            "SELECT *, (%(deleted)s) AS deleted FROM events "
             "WHERE outlier = 0 AND room_id = ? AND %(bounds)s "
             "ORDER BY topological_ordering %(order)s, stream_ordering %(order)s %(limit)s "
-        ) % {"bounds": bounds, "order": order, "limit": limit_str}
+        ) % {
+            "deleted": del_sql,
+            "bounds": bounds,
+            "order": order,
+            "limit": limit_str
+        }
 
         rows = yield self._execute_and_decode(
             sql,
@@ -257,11 +271,17 @@ class StreamStore(SQLBaseStore):
                                    with_feedback=False):
         # TODO (erikj): Handle compressed feedback
 
+        del_sql = (
+            "SELECT event_id FROM deletions WHERE deletes = events.event_id"
+        )
+
         sql = (
-            "SELECT * FROM events "
+            "SELECT *, (%(deleted)s) AS deleted FROM events "
             "WHERE room_id = ? AND stream_ordering <= ? "
             "ORDER BY topological_ordering DESC, stream_ordering DESC LIMIT ? "
-        )
+        ) % {
+            "deleted": del_sql,
+        }
 
         rows = yield self._execute_and_decode(
             sql,