Pass through list of room hosts from room alias query to federation so that it can retry against different room hosts
This commit is contained in:
parent
8046df6efa
commit
e1515c3e91
|
@ -264,7 +264,9 @@ class FederationClient(FederationBase):
|
||||||
|
|
||||||
logger.debug("Got response to make_join: %s", pdu_dict)
|
logger.debug("Got response to make_join: %s", pdu_dict)
|
||||||
|
|
||||||
defer.returnValue(self.event_from_pdu_json(pdu_dict))
|
defer.returnValue(
|
||||||
|
(destination, self.event_from_pdu_json(pdu_dict))
|
||||||
|
)
|
||||||
break
|
break
|
||||||
except CodeMessageException:
|
except CodeMessageException:
|
||||||
raise
|
raise
|
||||||
|
@ -313,6 +315,7 @@ class FederationClient(FederationBase):
|
||||||
defer.returnValue({
|
defer.returnValue({
|
||||||
"state": signed_state,
|
"state": signed_state,
|
||||||
"auth_chain": signed_auth,
|
"auth_chain": signed_auth,
|
||||||
|
"origin": destination,
|
||||||
})
|
})
|
||||||
except CodeMessageException:
|
except CodeMessageException:
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -273,7 +273,7 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
@log_function
|
@log_function
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def do_invite_join(self, target_host, room_id, joinee, content, snapshot):
|
def do_invite_join(self, target_hosts, room_id, joinee, content, snapshot):
|
||||||
""" Attempts to join the `joinee` to the room `room_id` via the
|
""" Attempts to join the `joinee` to the room `room_id` via the
|
||||||
server `target_host`.
|
server `target_host`.
|
||||||
|
|
||||||
|
@ -287,8 +287,8 @@ class FederationHandler(BaseHandler):
|
||||||
"""
|
"""
|
||||||
logger.debug("Joining %s to %s", joinee, room_id)
|
logger.debug("Joining %s to %s", joinee, room_id)
|
||||||
|
|
||||||
pdu = yield self.replication_layer.make_join(
|
origin, pdu = yield self.replication_layer.make_join(
|
||||||
[target_host],
|
target_hosts,
|
||||||
room_id,
|
room_id,
|
||||||
joinee
|
joinee
|
||||||
)
|
)
|
||||||
|
@ -330,11 +330,17 @@ class FederationHandler(BaseHandler):
|
||||||
|
|
||||||
new_event = builder.build()
|
new_event = builder.build()
|
||||||
|
|
||||||
|
# Try the host we successfully got a response to /make_join/
|
||||||
|
# request first.
|
||||||
|
target_hosts.remove(origin)
|
||||||
|
target_hosts.insert(0, origin)
|
||||||
|
|
||||||
ret = yield self.replication_layer.send_join(
|
ret = yield self.replication_layer.send_join(
|
||||||
[target_host],
|
target_hosts,
|
||||||
new_event
|
new_event
|
||||||
)
|
)
|
||||||
|
|
||||||
|
origin = ret["origin"]
|
||||||
state = ret["state"]
|
state = ret["state"]
|
||||||
auth_chain = ret["auth_chain"]
|
auth_chain = ret["auth_chain"]
|
||||||
auth_chain.sort(key=lambda e: e.depth)
|
auth_chain.sort(key=lambda e: e.depth)
|
||||||
|
@ -371,7 +377,7 @@ class FederationHandler(BaseHandler):
|
||||||
if e.event_id in auth_ids
|
if e.event_id in auth_ids
|
||||||
}
|
}
|
||||||
yield self._handle_new_event(
|
yield self._handle_new_event(
|
||||||
target_host, e, auth_events=auth
|
origin, e, auth_events=auth
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
|
@ -391,7 +397,7 @@ class FederationHandler(BaseHandler):
|
||||||
if e.event_id in auth_ids
|
if e.event_id in auth_ids
|
||||||
}
|
}
|
||||||
yield self._handle_new_event(
|
yield self._handle_new_event(
|
||||||
target_host, e, auth_events=auth
|
origin, e, auth_events=auth
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
|
@ -406,7 +412,7 @@ class FederationHandler(BaseHandler):
|
||||||
}
|
}
|
||||||
|
|
||||||
yield self._handle_new_event(
|
yield self._handle_new_event(
|
||||||
target_host,
|
origin,
|
||||||
new_event,
|
new_event,
|
||||||
state=state,
|
state=state,
|
||||||
current_state=state,
|
current_state=state,
|
||||||
|
|
|
@ -389,8 +389,6 @@ class RoomMemberHandler(BaseHandler):
|
||||||
if not hosts:
|
if not hosts:
|
||||||
raise SynapseError(404, "No known servers")
|
raise SynapseError(404, "No known servers")
|
||||||
|
|
||||||
host = hosts[0]
|
|
||||||
|
|
||||||
# If event doesn't include a display name, add one.
|
# If event doesn't include a display name, add one.
|
||||||
yield self.distributor.fire(
|
yield self.distributor.fire(
|
||||||
"collect_presencelike_data", joinee, content
|
"collect_presencelike_data", joinee, content
|
||||||
|
@ -407,12 +405,12 @@ class RoomMemberHandler(BaseHandler):
|
||||||
})
|
})
|
||||||
event, context = yield self._create_new_client_event(builder)
|
event, context = yield self._create_new_client_event(builder)
|
||||||
|
|
||||||
yield self._do_join(event, context, room_host=host, do_auth=True)
|
yield self._do_join(event, context, room_hosts=hosts, do_auth=True)
|
||||||
|
|
||||||
defer.returnValue({"room_id": room_id})
|
defer.returnValue({"room_id": room_id})
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _do_join(self, event, context, room_host=None, do_auth=True):
|
def _do_join(self, event, context, room_hosts=None, do_auth=True):
|
||||||
joinee = UserID.from_string(event.state_key)
|
joinee = UserID.from_string(event.state_key)
|
||||||
# room_id = RoomID.from_string(event.room_id, self.hs)
|
# room_id = RoomID.from_string(event.room_id, self.hs)
|
||||||
room_id = event.room_id
|
room_id = event.room_id
|
||||||
|
@ -441,7 +439,7 @@ class RoomMemberHandler(BaseHandler):
|
||||||
|
|
||||||
if is_host_in_room:
|
if is_host_in_room:
|
||||||
should_do_dance = False
|
should_do_dance = False
|
||||||
elif room_host: # TODO: Shouldn't this be remote_room_host?
|
elif room_hosts: # TODO: Shouldn't this be remote_room_host?
|
||||||
should_do_dance = True
|
should_do_dance = True
|
||||||
else:
|
else:
|
||||||
# TODO(markjh): get prev_state from snapshot
|
# TODO(markjh): get prev_state from snapshot
|
||||||
|
@ -453,7 +451,7 @@ class RoomMemberHandler(BaseHandler):
|
||||||
inviter = UserID.from_string(prev_state.user_id)
|
inviter = UserID.from_string(prev_state.user_id)
|
||||||
|
|
||||||
should_do_dance = not self.hs.is_mine(inviter)
|
should_do_dance = not self.hs.is_mine(inviter)
|
||||||
room_host = inviter.domain
|
room_hosts = [inviter.domain]
|
||||||
else:
|
else:
|
||||||
# return the same error as join_room_alias does
|
# return the same error as join_room_alias does
|
||||||
raise SynapseError(404, "No known servers")
|
raise SynapseError(404, "No known servers")
|
||||||
|
@ -461,7 +459,7 @@ class RoomMemberHandler(BaseHandler):
|
||||||
if should_do_dance:
|
if should_do_dance:
|
||||||
handler = self.hs.get_handlers().federation_handler
|
handler = self.hs.get_handlers().federation_handler
|
||||||
yield handler.do_invite_join(
|
yield handler.do_invite_join(
|
||||||
room_host,
|
room_hosts,
|
||||||
room_id,
|
room_id,
|
||||||
event.user_id,
|
event.user_id,
|
||||||
event.get_dict()["content"], # FIXME To get a non-frozen dict
|
event.get_dict()["content"], # FIXME To get a non-frozen dict
|
||||||
|
|
Loading…
Reference in New Issue