mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Remove hack to support rejoining rooms
This commit is contained in:
parent
30dd27afff
commit
dc59ad5334
@ -552,86 +552,54 @@ class FederationHandler(BaseHandler):
|
|||||||
room_id, event_id, event,
|
room_id, event_id, event,
|
||||||
)
|
)
|
||||||
|
|
||||||
# FIXME (erikj): Awful hack to make the case where we are not currently
|
event_ids = set()
|
||||||
# in the room work
|
if state:
|
||||||
# If state and auth_chain are None, then we don't need to do this check
|
event_ids |= {e.event_id for e in state}
|
||||||
# as we already know we have enough state in the DB to handle this
|
if auth_chain:
|
||||||
# event.
|
event_ids |= {e.event_id for e in auth_chain}
|
||||||
if state and auth_chain and not event.internal_metadata.is_outlier():
|
|
||||||
is_in_room = yield self.auth.check_host_in_room(
|
seen_ids = yield self.store.have_seen_events(event_ids)
|
||||||
room_id,
|
|
||||||
self.server_name
|
if state and auth_chain is not None:
|
||||||
)
|
# If we have any state or auth_chain given to us by the replication
|
||||||
else:
|
# layer, then we should handle them (if we haven't before.)
|
||||||
is_in_room = True
|
|
||||||
|
event_infos = []
|
||||||
|
|
||||||
|
for e in itertools.chain(auth_chain, state):
|
||||||
|
if e.event_id in seen_ids:
|
||||||
|
continue
|
||||||
|
e.internal_metadata.outlier = True
|
||||||
|
auth_ids = e.auth_event_ids()
|
||||||
|
auth = {
|
||||||
|
(e.type, e.state_key): e for e in auth_chain
|
||||||
|
if e.event_id in auth_ids or e.type == EventTypes.Create
|
||||||
|
}
|
||||||
|
event_infos.append({
|
||||||
|
"event": e,
|
||||||
|
"auth_events": auth,
|
||||||
|
})
|
||||||
|
seen_ids.add(e.event_id)
|
||||||
|
|
||||||
if not is_in_room:
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"[%s %s] Got event for room we're not in",
|
"[%s %s] persisting newly-received auth/state events %s",
|
||||||
room_id, event_id,
|
room_id, event_id, [e["event"].event_id for e in event_infos]
|
||||||
)
|
)
|
||||||
|
yield self._handle_new_events(origin, event_infos)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
yield self._persist_auth_tree(
|
context = yield self._handle_new_event(
|
||||||
origin, auth_chain, state, event
|
origin,
|
||||||
)
|
event,
|
||||||
except AuthError as e:
|
state=state,
|
||||||
raise FederationError(
|
)
|
||||||
"ERROR",
|
except AuthError as e:
|
||||||
e.code,
|
raise FederationError(
|
||||||
e.msg,
|
"ERROR",
|
||||||
affected=event_id,
|
e.code,
|
||||||
)
|
e.msg,
|
||||||
|
affected=event.event_id,
|
||||||
else:
|
)
|
||||||
event_ids = set()
|
|
||||||
if state:
|
|
||||||
event_ids |= {e.event_id for e in state}
|
|
||||||
if auth_chain:
|
|
||||||
event_ids |= {e.event_id for e in auth_chain}
|
|
||||||
|
|
||||||
seen_ids = yield self.store.have_seen_events(event_ids)
|
|
||||||
|
|
||||||
if state and auth_chain is not None:
|
|
||||||
# If we have any state or auth_chain given to us by the replication
|
|
||||||
# layer, then we should handle them (if we haven't before.)
|
|
||||||
|
|
||||||
event_infos = []
|
|
||||||
|
|
||||||
for e in itertools.chain(auth_chain, state):
|
|
||||||
if e.event_id in seen_ids:
|
|
||||||
continue
|
|
||||||
e.internal_metadata.outlier = True
|
|
||||||
auth_ids = e.auth_event_ids()
|
|
||||||
auth = {
|
|
||||||
(e.type, e.state_key): e for e in auth_chain
|
|
||||||
if e.event_id in auth_ids or e.type == EventTypes.Create
|
|
||||||
}
|
|
||||||
event_infos.append({
|
|
||||||
"event": e,
|
|
||||||
"auth_events": auth,
|
|
||||||
})
|
|
||||||
seen_ids.add(e.event_id)
|
|
||||||
|
|
||||||
logger.info(
|
|
||||||
"[%s %s] persisting newly-received auth/state events %s",
|
|
||||||
room_id, event_id, [e["event"].event_id for e in event_infos]
|
|
||||||
)
|
|
||||||
yield self._handle_new_events(origin, event_infos)
|
|
||||||
|
|
||||||
try:
|
|
||||||
context = yield self._handle_new_event(
|
|
||||||
origin,
|
|
||||||
event,
|
|
||||||
state=state,
|
|
||||||
)
|
|
||||||
except AuthError as e:
|
|
||||||
raise FederationError(
|
|
||||||
"ERROR",
|
|
||||||
e.code,
|
|
||||||
e.msg,
|
|
||||||
affected=event.event_id,
|
|
||||||
)
|
|
||||||
|
|
||||||
room = yield self.store.get_room(room_id)
|
room = yield self.store.get_room(room_id)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user