@defer.inlineCallbacks
    def do_remotely_reject_invite(self, target_hosts, room_id, user_id):
        origin, event = yield self._make_and_verify_event(
            target_hosts,
            room_id,
            user_id,
            "leave"
        )
        signed_event = self._sign_event(event)

        # Try the host we successfully got a response to /make_join/
        # request first.
        try:
            target_hosts.remove(origin)
            target_hosts.insert(0, origin)
        except __HOLE__:
            pass

        yield self.replication_layer.send_leave(
            target_hosts,
            signed_event
        )

        context = yield self.state_handler.compute_event_context(event)

        event_stream_id, max_stream_id = yield self.store.persist_event(
            event,
            context=context,
        )

        target_user = UserID.from_string(event.state_key)
        self.notifier.on_new_room_event(
            event, event_stream_id, max_stream_id,
            extra_users=[target_user],
        )

        defer.returnValue(event)
dataset/ETHPy150Open matrix-org/synapse/synapse/handlers/federation.py/FederationHandler.do_remotely_reject_invite