diff options
author | Erik Johnston <erikj@jki.re> | 2019-02-25 15:53:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-25 15:53:10 +0000 |
commit | b1a90da82e56d9702e4510fad365377d87908f1c (patch) | |
tree | cef37b64de3da97c49493ba5e6f114b0a98af33c /synapse/federation/federation_client.py | |
parent | Merge pull request #4722 from matrix-org/erikj/correctly_handle_keyring_excep... (diff) | |
parent | Newsfile (diff) | |
download | synapse-b1a90da82e56d9702e4510fad365377d87908f1c.tar.xz |
Merge pull request #4721 from matrix-org/erikj/msc_1866
MSC 1866 - Use M_UNSUPPORTED_ROOM_VERSION for invite API
Diffstat (limited to 'synapse/federation/federation_client.py')
-rw-r--r-- | synapse/federation/federation_client.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/synapse/federation/federation_client.py b/synapse/federation/federation_client.py index 4e4f58b418..58e04d81ab 100644 --- a/synapse/federation/federation_client.py +++ b/synapse/federation/federation_client.py @@ -33,6 +33,7 @@ from synapse.api.constants import ( ) from synapse.api.errors import ( CodeMessageException, + Codes, FederationDeniedError, HttpResponseException, SynapseError, @@ -792,10 +793,25 @@ class FederationClient(FederationBase): defer.returnValue(content) except HttpResponseException as e: if e.code in [400, 404]: + err = e.to_synapse_error() + + # If we receive an error response that isn't a generic error, we + # assume that the remote understands the v2 invite API and this + # is a legitimate error. + if err.errcode != Codes.UNKNOWN: + raise err + + # Otherwise, we assume that the remote server doesn't understand + # the v2 invite API. + if room_version in (RoomVersions.V1, RoomVersions.V2): pass # We'll fall through else: - raise Exception("Remote server is too old") + raise SynapseError( + 400, + "User's homeserver does not support this room version", + Codes.UNSUPPORTED_ROOM_VERSION, + ) elif e.code == 403: raise e.to_synapse_error() else: |