summary refs log tree commit diff
path: root/synapse/handlers/federation.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-09-02 10:49:43 +0100
committerErik Johnston <erik@matrix.org>2016-09-02 10:53:36 +0100
commit2854ee2a52226df9f29acb7d8c141af2a6546d21 (patch)
treedcc91870df134e6a3c7526d46d1e155d0cfe740b /synapse/handlers/federation.py
parentMerge pull request #1061 from matrix-org/erikj/linearize_resolution (diff)
downloadsynapse-2854ee2a52226df9f29acb7d8c141af2a6546d21.tar.xz
Only pull out IDs from DB for /state_ids/ request
Diffstat (limited to '')
-rw-r--r--synapse/handlers/federation.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index 8e61d74b13..fda09b21c0 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -1103,6 +1103,32 @@ class FederationHandler(BaseHandler):
             defer.returnValue([])
 
     @defer.inlineCallbacks
+    def get_state_ids_for_pdu(self, room_id, event_id):
+        yield run_on_reactor()
+
+        state_groups = yield self.store.get_state_groups_ids(
+            room_id, [event_id]
+        )
+
+        if state_groups:
+            _, state = state_groups.items().pop()
+            results = state
+
+            event = yield self.store.get_event(event_id)
+            if event and event.is_state():
+                # Get previous state
+                if "replaces_state" in event.unsigned:
+                    prev_id = event.unsigned["replaces_state"]
+                    if prev_id != event.event_id:
+                        results[(event.type, event.state_key)] = prev_id
+                else:
+                    del results[(event.type, event.state_key)]
+
+            defer.returnValue(results.values())
+        else:
+            defer.returnValue([])
+
+    @defer.inlineCallbacks
     @log_function
     def on_backfill_request(self, origin, room_id, pdu_list, limit):
         in_room = yield self.auth.check_host_in_room(room_id, origin)