diff options
author | Erik Johnston <erik@matrix.org> | 2014-11-24 12:56:17 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-11-24 12:56:17 +0000 |
commit | 4bd0ab76c69b8f4861de26894f8e50407e9fc87f (patch) | |
tree | efb13721713d72d91d8f6c7e6574db2a9c6be875 | |
parent | SYN-163: Add an order by rowid to selects. (diff) | |
download | synapse-4bd0ab76c69b8f4861de26894f8e50407e9fc87f.tar.xz |
We don't always want to Auth get_persisted_pdu
Diffstat (limited to '')
-rw-r--r-- | synapse/federation/replication.py | 16 | ||||
-rw-r--r-- | synapse/handlers/federation.py | 15 |
2 files changed, 20 insertions, 11 deletions
diff --git a/synapse/federation/replication.py b/synapse/federation/replication.py index 124dc31225..4cd17bdb9c 100644 --- a/synapse/federation/replication.py +++ b/synapse/federation/replication.py @@ -504,13 +504,15 @@ class ReplicationLayer(object): defer.returnValue(self.event_from_pdu_json(pdu_dict)) @log_function - def _get_persisted_pdu(self, origin, event_id): + def _get_persisted_pdu(self, origin, event_id, do_auth=True): """ Get a PDU from the database with given origin and id. Returns: Deferred: Results in a `Pdu`. """ - return self.handler.get_persisted_pdu(origin, event_id) + return self.handler.get_persisted_pdu( + origin, event_id, do_auth=do_auth + ) def _transaction_from_pdus(self, pdu_list): """Returns a new Transaction containing the given PDUs suitable for @@ -529,7 +531,9 @@ class ReplicationLayer(object): @log_function def _handle_new_pdu(self, origin, pdu, backfilled=False): # We reprocess pdus when we have seen them only as outliers - existing = yield self._get_persisted_pdu(origin, pdu.event_id) + existing = yield self._get_persisted_pdu( + origin, pdu.event_id, do_auth=False + ) if existing and (not existing.outlier or pdu.outlier): logger.debug("Already seen pdu %s", pdu.event_id) @@ -547,7 +551,11 @@ class ReplicationLayer(object): if min_depth and pdu.depth > min_depth: for event_id, hashes in pdu.prev_events: - exists = yield self._get_persisted_pdu(origin, event_id) + exists = yield self._get_persisted_pdu( + origin, + event_id, + do_auth=False + ) if not exists: logger.debug("Requesting pdu %s", event_id) diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 2e8b8a1f9a..f601de4488 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -529,7 +529,7 @@ class FederationHandler(BaseHandler): @defer.inlineCallbacks @log_function - def get_persisted_pdu(self, origin, event_id): + def get_persisted_pdu(self, origin, event_id, do_auth=True): """ Get a PDU from the database with given origin and id. Returns: @@ -541,12 +541,13 @@ class FederationHandler(BaseHandler): ) if event: - in_room = yield self.auth.check_host_in_room( - event.room_id, - origin - ) - if not in_room: - raise AuthError(403, "Host not in room.") + if do_auth: + in_room = yield self.auth.check_host_in_room( + event.room_id, + origin + ) + if not in_room: + raise AuthError(403, "Host not in room.") defer.returnValue(event) else: |