summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-08-27 13:34:28 +0100
committerMark Haines <mark.haines@matrix.org>2014-08-27 14:32:19 +0100
commita03c7f27a8104d0e32642cb96faf24608dc2e27b (patch)
tree66e50f91396082e58643e32194fe0322735dcb92 /synapse/storage
parentRemove unused populate_previous_pdus (diff)
downloadsynapse-a03c7f27a8104d0e32642cb96faf24608dc2e27b.tar.xz
Fill out prev_events before calling persist_event
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/__init__.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py
index 08505f05ff..8c2c82c1bb 100644
--- a/synapse/storage/__init__.py
+++ b/synapse/storage/__init__.py
@@ -58,12 +58,6 @@ class DataStore(RoomMemberStore, RoomStore,
     @defer.inlineCallbacks
     @log_function
     def persist_event(self, event=None, backfilled=False, pdu=None):
-        # FIXME (erikj): This should be removed when we start amalgamating
-        # event and pdu storage
-        if event is not None:
-            federation_handler = self.hs.get_handlers().federation_handler
-            yield federation_handler.fill_out_prev_events(event)
-
         stream_ordering = None
         if backfilled:
             if not self.min_token_deferred.called:
@@ -290,6 +284,21 @@ class Snapshot(object):
         self.state_key = state_key
         self.prev_state_pdu = prev_state_pdu
 
+    def fill_out_prev_events(self, event):
+        if hasattr(event, "prev_events"):
+            return
+
+        es = [
+            "%s@%s" % (p_id, origin) for p_id, origin, _ in self.prev_pdus
+        ]
+
+        event.prev_events = [e for e in es if e != event.event_id]
+
+        if self.prev_pdus:
+            event.depth = max([int(v) for _, _, v in results]) + 1
+        else:
+            event.depth = 0
+
 
 def schema_path(schema):
     """ Get a filesystem path for the named database schema