diff options
author | Erik Johnston <erik@matrix.org> | 2016-08-05 11:15:48 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-08-05 11:15:48 +0100 |
commit | 499dc1b349988e23ab26f829b2005f617134e6c0 (patch) | |
tree | 866dec5ab910b42fd22b5826721c0ec7f8ad7cff /synapse/federation/federation_server.py | |
parent | Bump version and changelog (diff) | |
parent | Merge pull request #986 from matrix-org/erikj/state (diff) | |
download | synapse-499dc1b349988e23ab26f829b2005f617134e6c0.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into release-v0.17.0
Diffstat (limited to 'synapse/federation/federation_server.py')
-rw-r--r-- | synapse/federation/federation_server.py | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py index 612d274bdb..aba19639c7 100644 --- a/synapse/federation/federation_server.py +++ b/synapse/federation/federation_server.py @@ -215,6 +215,27 @@ class FederationServer(FederationBase): defer.returnValue((200, resp)) @defer.inlineCallbacks + def on_state_ids_request(self, origin, room_id, event_id): + if not event_id: + raise NotImplementedError("Specify an event") + + in_room = yield self.auth.check_host_in_room(room_id, origin) + if not in_room: + raise AuthError(403, "Host not in room.") + + pdus = yield self.handler.get_state_for_pdu( + room_id, event_id, + ) + auth_chain = yield self.store.get_auth_chain( + [pdu.event_id for pdu in pdus] + ) + + defer.returnValue((200, { + "pdu_ids": [pdu.event_id for pdu in pdus], + "auth_chain_ids": [pdu.event_id for pdu in auth_chain], + })) + + @defer.inlineCallbacks def _on_context_state_request_compute(self, room_id, event_id): pdus = yield self.handler.get_state_for_pdu( room_id, event_id, @@ -372,27 +393,9 @@ class FederationServer(FederationBase): (200, send_content) ) - @defer.inlineCallbacks @log_function def on_query_client_keys(self, origin, content): - query = [] - for user_id, device_ids in content.get("device_keys", {}).items(): - if not device_ids: - query.append((user_id, None)) - else: - for device_id in device_ids: - query.append((user_id, device_id)) - - results = yield self.store.get_e2e_device_keys(query) - - json_result = {} - for user_id, device_keys in results.items(): - for device_id, json_bytes in device_keys.items(): - json_result.setdefault(user_id, {})[device_id] = json.loads( - json_bytes - ) - - defer.returnValue({"device_keys": json_result}) + return self.on_query_request("client_keys", content) @defer.inlineCallbacks @log_function @@ -602,7 +605,7 @@ class FederationServer(FederationBase): origin, pdu.room_id, pdu.event_id, ) except: - logger.warn("Failed to get state for event: %s", pdu.event_id) + logger.exception("Failed to get state for event: %s", pdu.event_id) yield self.handler.on_receive_pdu( origin, |