mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
SYN-154: Better error messages when joining an unknown room by ID.
The simple fix doesn't work here because room creation also involves unknown room IDs. The check relies on the presence of m.room.create for rooms being created, whereas bogus room IDs have no state events at all.
This commit is contained in:
parent
9b8e348b15
commit
9cb4f75d53
@ -98,7 +98,16 @@ class Auth(object):
|
|||||||
defer.returnValue(member)
|
defer.returnValue(member)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def check_host_in_room(self, room_id, host):
|
def check_host_in_room(self, room_id, host, context=None):
|
||||||
|
if context:
|
||||||
|
# XXX: check_host_in_room should really return True for a new
|
||||||
|
# room created by this home server. There are no m.room.member
|
||||||
|
# join events yet so we need to check for the m.room.create event
|
||||||
|
# instead.
|
||||||
|
if (u"m.room.create", u"") in context.auth_events:
|
||||||
|
defer.returnValue(True)
|
||||||
|
return
|
||||||
|
|
||||||
curr_state = yield self.state.get_current_state(room_id)
|
curr_state = yield self.state.get_current_state(room_id)
|
||||||
|
|
||||||
for event in curr_state:
|
for event in curr_state:
|
||||||
|
@ -617,8 +617,8 @@ class FederationHandler(BaseHandler):
|
|||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
@log_function
|
@log_function
|
||||||
def on_backfill_request(self, origin, context, pdu_list, limit):
|
def on_backfill_request(self, origin, room_id, pdu_list, limit):
|
||||||
in_room = yield self.auth.check_host_in_room(context, origin)
|
in_room = yield self.auth.check_host_in_room(room_id, origin)
|
||||||
if not in_room:
|
if not in_room:
|
||||||
raise AuthError(403, "Host not in room.")
|
raise AuthError(403, "Host not in room.")
|
||||||
|
|
||||||
|
@ -423,12 +423,13 @@ class RoomMemberHandler(BaseHandler):
|
|||||||
|
|
||||||
is_host_in_room = yield self.auth.check_host_in_room(
|
is_host_in_room = yield self.auth.check_host_in_room(
|
||||||
event.room_id,
|
event.room_id,
|
||||||
self.hs.hostname
|
self.hs.hostname,
|
||||||
|
context=context
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_host_in_room:
|
if is_host_in_room:
|
||||||
should_do_dance = False
|
should_do_dance = False
|
||||||
elif room_host:
|
elif room_host: # 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
|
||||||
@ -442,7 +443,8 @@ class RoomMemberHandler(BaseHandler):
|
|||||||
should_do_dance = not self.hs.is_mine(inviter)
|
should_do_dance = not self.hs.is_mine(inviter)
|
||||||
room_host = inviter.domain
|
room_host = inviter.domain
|
||||||
else:
|
else:
|
||||||
should_do_dance = False
|
# return the same error as join_room_alias does
|
||||||
|
raise SynapseError(404, "No known servers")
|
||||||
|
|
||||||
if should_do_dance:
|
if should_do_dance:
|
||||||
handler = self.hs.get_handlers().federation_handler
|
handler = self.hs.get_handlers().federation_handler
|
||||||
|
Loading…
Reference in New Issue
Block a user