summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-01-25 17:19:31 +0000
committerErik Johnston <erik@matrix.org>2019-01-29 11:13:00 +0000
commitbe47cfa9c97b4acfd884440f1953ed000225eb37 (patch)
tree3e274c1b99d45ba4f1eba89d4553060b301f83d1 /synapse/storage
parentMake add_hashes_and_signatures operate on dicts (diff)
downloadsynapse-be47cfa9c97b4acfd884440f1953ed000225eb37.tar.xz
Refactor event building into EventBuilder
This is so that everything is done in one place, making it easier to
change the event format based on room version
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/event_federation.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/synapse/storage/event_federation.py b/synapse/storage/event_federation.py
index d3b9dea1d6..38809ed0fc 100644
--- a/synapse/storage/event_federation.py
+++ b/synapse/storage/event_federation.py
@@ -125,6 +125,29 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore,
 
         return dict(txn)
 
+    @defer.inlineCallbacks
+    def get_max_depth_of(self, event_ids):
+        """Returns the max depth of a set of event IDs
+
+        Args:
+            event_ids (list[str])
+
+        Returns
+            Deferred[int]
+        """
+        rows = yield self._simple_select_many_batch(
+            table="events",
+            column="event_id",
+            iterable=event_ids,
+            retcols=("depth",),
+            desc="get_max_depth_of",
+        )
+
+        if not rows:
+            defer.returnValue(0)
+        else:
+            defer.returnValue(max(row["depth"] for row in rows))
+
     def _get_oldest_events_in_room_txn(self, txn, room_id):
         return self._simple_select_onecol_txn(
             txn,