Merge pull request #1064 from matrix-org/erikj/on_receive_check
Only check if host is in room if we have state and auth_chainpull/1069/head
commit
273b6bcf22
|
@ -101,6 +101,9 @@ class FederationHandler(BaseHandler):
|
||||||
def on_receive_pdu(self, origin, pdu, state=None, auth_chain=None):
|
def on_receive_pdu(self, origin, pdu, state=None, auth_chain=None):
|
||||||
""" Called by the ReplicationLayer when we have a new pdu. We need to
|
""" Called by the ReplicationLayer when we have a new pdu. We need to
|
||||||
do auth checks and put it through the StateHandler.
|
do auth checks and put it through the StateHandler.
|
||||||
|
|
||||||
|
auth_chain and state are None if we already have the necessary state
|
||||||
|
and prev_events in the db
|
||||||
"""
|
"""
|
||||||
event = pdu
|
event = pdu
|
||||||
|
|
||||||
|
@ -118,12 +121,21 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
# FIXME (erikj): Awful hack to make the case where we are not currently
|
# FIXME (erikj): Awful hack to make the case where we are not currently
|
||||||
# in the room work
|
# in the room work
|
||||||
is_in_room = yield self.auth.check_host_in_room(
|
# If state and auth_chain are None, then we don't need to do this check
|
||||||
event.room_id,
|
# as we already know we have enough state in the DB to handle this
|
||||||
self.server_name
|
# event.
|
||||||
)
|
if state and auth_chain and not event.internal_metadata.is_outlier():
|
||||||
if not is_in_room and not event.internal_metadata.is_outlier():
|
is_in_room = yield self.auth.check_host_in_room(
|
||||||
logger.debug("Got event for room we're not in.")
|
event.room_id,
|
||||||
|
self.server_name
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
is_in_room = True
|
||||||
|
if not is_in_room:
|
||||||
|
logger.info(
|
||||||
|
"Got event for room we're not in: %r %r",
|
||||||
|
event.room_id, event.event_id
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
event_stream_id, max_stream_id = yield self._persist_auth_tree(
|
event_stream_id, max_stream_id = yield self._persist_auth_tree(
|
||||||
|
|
Loading…
Reference in New Issue