0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-15 06:21:49 +01:00

Propagate reason in remotely rejected invites

This commit is contained in:
Erik Johnston 2019-11-28 11:31:56 +00:00
parent 69d8fb83c6
commit 2173785f0d
4 changed files with 20 additions and 9 deletions

View file

@ -1428,9 +1428,9 @@ class FederationHandler(BaseHandler):
return event return event
@defer.inlineCallbacks @defer.inlineCallbacks
def do_remotely_reject_invite(self, target_hosts, room_id, user_id): def do_remotely_reject_invite(self, target_hosts, room_id, user_id, content):
origin, event, event_format_version = yield self._make_and_verify_event( origin, event, event_format_version = yield self._make_and_verify_event(
target_hosts, room_id, user_id, "leave" target_hosts, room_id, user_id, "leave", content=content,
) )
# Mark as outlier as we don't have any state for this event; we're not # Mark as outlier as we don't have any state for this event; we're not
# even in the room. # even in the room.

View file

@ -94,7 +94,9 @@ class RoomMemberHandler(object):
raise NotImplementedError() raise NotImplementedError()
@abc.abstractmethod @abc.abstractmethod
def _remote_reject_invite(self, requester, remote_room_hosts, room_id, target): def _remote_reject_invite(
self, requester, remote_room_hosts, room_id, target, content
):
"""Attempt to reject an invite for a room this server is not in. If we """Attempt to reject an invite for a room this server is not in. If we
fail to do so we locally mark the invite as rejected. fail to do so we locally mark the invite as rejected.
@ -104,6 +106,7 @@ class RoomMemberHandler(object):
reject invite reject invite
room_id (str) room_id (str)
target (UserID): The user rejecting the invite target (UserID): The user rejecting the invite
content (dict): The content for the rejection event
Returns: Returns:
Deferred[dict]: A dictionary to be returned to the client, may Deferred[dict]: A dictionary to be returned to the client, may
@ -471,7 +474,7 @@ class RoomMemberHandler(object):
# send the rejection to the inviter's HS. # send the rejection to the inviter's HS.
remote_room_hosts = remote_room_hosts + [inviter.domain] remote_room_hosts = remote_room_hosts + [inviter.domain]
res = yield self._remote_reject_invite( res = yield self._remote_reject_invite(
requester, remote_room_hosts, room_id, target requester, remote_room_hosts, room_id, target, content,
) )
return res return res
@ -971,13 +974,15 @@ class RoomMemberMasterHandler(RoomMemberHandler):
) )
@defer.inlineCallbacks @defer.inlineCallbacks
def _remote_reject_invite(self, requester, remote_room_hosts, room_id, target): def _remote_reject_invite(
self, requester, remote_room_hosts, room_id, target, content
):
"""Implements RoomMemberHandler._remote_reject_invite """Implements RoomMemberHandler._remote_reject_invite
""" """
fed_handler = self.federation_handler fed_handler = self.federation_handler
try: try:
ret = yield fed_handler.do_remotely_reject_invite( ret = yield fed_handler.do_remotely_reject_invite(
remote_room_hosts, room_id, target.to_string() remote_room_hosts, room_id, target.to_string(), content=content,
) )
return ret return ret
except Exception as e: except Exception as e:

View file

@ -55,7 +55,9 @@ class RoomMemberWorkerHandler(RoomMemberHandler):
return ret return ret
def _remote_reject_invite(self, requester, remote_room_hosts, room_id, target): def _remote_reject_invite(
self, requester, remote_room_hosts, room_id, target, content
):
"""Implements RoomMemberHandler._remote_reject_invite """Implements RoomMemberHandler._remote_reject_invite
""" """
return self._remote_reject_client( return self._remote_reject_client(
@ -63,6 +65,7 @@ class RoomMemberWorkerHandler(RoomMemberHandler):
remote_room_hosts=remote_room_hosts, remote_room_hosts=remote_room_hosts,
room_id=room_id, room_id=room_id,
user_id=target.to_string(), user_id=target.to_string(),
content=content,
) )
def _user_joined_room(self, target, room_id): def _user_joined_room(self, target, room_id):

View file

@ -93,6 +93,7 @@ class ReplicationRemoteRejectInviteRestServlet(ReplicationEndpoint):
{ {
"requester": ..., "requester": ...,
"remote_room_hosts": [...], "remote_room_hosts": [...],
"content": { ... }
} }
""" """
@ -107,7 +108,7 @@ class ReplicationRemoteRejectInviteRestServlet(ReplicationEndpoint):
self.clock = hs.get_clock() self.clock = hs.get_clock()
@staticmethod @staticmethod
def _serialize_payload(requester, room_id, user_id, remote_room_hosts): def _serialize_payload(requester, room_id, user_id, remote_room_hosts, content):
""" """
Args: Args:
requester(Requester) requester(Requester)
@ -118,12 +119,14 @@ class ReplicationRemoteRejectInviteRestServlet(ReplicationEndpoint):
return { return {
"requester": requester.serialize(), "requester": requester.serialize(),
"remote_room_hosts": remote_room_hosts, "remote_room_hosts": remote_room_hosts,
"content": content,
} }
async def _handle_request(self, request, room_id, user_id): async def _handle_request(self, request, room_id, user_id):
content = parse_json_object_from_request(request) content = parse_json_object_from_request(request)
remote_room_hosts = content["remote_room_hosts"] remote_room_hosts = content["remote_room_hosts"]
event_content = content["content"]
requester = Requester.deserialize(self.store, content["requester"]) requester = Requester.deserialize(self.store, content["requester"])
@ -134,7 +137,7 @@ class ReplicationRemoteRejectInviteRestServlet(ReplicationEndpoint):
try: try:
event = await self.federation_handler.do_remotely_reject_invite( event = await self.federation_handler.do_remotely_reject_invite(
remote_room_hosts, room_id, user_id remote_room_hosts, room_id, user_id, event_content,
) )
ret = event.get_pdu_json() ret = event.get_pdu_json()
except Exception as e: except Exception as e: