This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ Faster Room Joins: prevent Synapse from answering federated join requests for a room which it has not fully joined yet.
Original file line number Diff line number Diff line change @@ -843,8 +843,25 @@ async def _on_send_membership_event(
843843 Codes .BAD_JSON ,
844844 )
845845
846+ # Note that get_room_version throws if the room does not exist here.
846847 room_version = await self .store .get_room_version (room_id )
847848
849+ if await self .store .is_partial_state_room (room_id ):
850+ # If our server is still only partially joined, we can't give a complete
851+ # response to /send_join, /send_knock or /send_leave.
852+ # This is because we will not be able to provide the server list (for partial
853+ # joins) or the full state (for full joins).
854+ # Return a 404 as we would if we weren't in the room at all.
855+ logger .info (
856+ f"Rejecting /send_{ membership_type } to %s because it's a partial state room" ,
857+ room_id ,
858+ )
859+ raise SynapseError (
860+ 404 ,
861+ f"Unable to handle /send_{ membership_type } right now; this server is not fully joined." ,
862+ errcode = Codes .NOT_FOUND ,
863+ )
864+
848865 if membership_type == Membership .KNOCK and not room_version .msc2403_knocking :
849866 raise SynapseError (
850867 403 ,
Original file line number Diff line number Diff line change @@ -754,6 +754,23 @@ async def on_make_join_request(
754754 # (and return a 404 otherwise)
755755 room_version = await self .store .get_room_version (room_id )
756756
757+ if await self .store .is_partial_state_room (room_id ):
758+ # If our server is still only partially joined, we can't give a complete
759+ # response to /make_join, so return a 404 as we would if we weren't in the
760+ # room at all.
761+ # The main reason we can't respond properly is that we need to know about
762+ # the auth events for the join event that we would return.
763+ # We also should not bother entertaining the /make_join since we cannot
764+ # handle the /send_join.
765+ logger .info (
766+ "Rejecting /make_join to %s because it's a partial state room" , room_id
767+ )
768+ raise SynapseError (
769+ 404 ,
770+ "Unable to handle /make_join right now; this server is not fully joined." ,
771+ errcode = Codes .NOT_FOUND ,
772+ )
773+
757774 # now check that we are *still* in the room
758775 is_in_room = await self ._event_auth_handler .check_host_in_room (
759776 room_id , self .server_name
You can’t perform that action at this time.
0 commit comments