diff options
author | Brendan Abolivier <babolivier@matrix.org> | 2019-07-08 14:19:39 +0100 |
---|---|---|
committer | Brendan Abolivier <babolivier@matrix.org> | 2019-07-08 14:19:39 +0100 |
commit | 1a807dfe6855b15d8574eb92541dd84b946f16bd (patch) | |
tree | 545fed918773f2001bb826bb9e76b829b1786d15 /synapse/handlers | |
parent | Docker image: Add a migrate_config mode (#5567) (diff) | |
download | synapse-1a807dfe6855b15d8574eb92541dd84b946f16bd.tar.xz |
Use application/json when querying the IS's /store-invite endpoint
Diffstat (limited to '')
-rw-r--r-- | synapse/handlers/room_member.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/synapse/handlers/room_member.py b/synapse/handlers/room_member.py index 4d6e883802..b050967b8f 100644 --- a/synapse/handlers/room_member.py +++ b/synapse/handlers/room_member.py @@ -29,7 +29,7 @@ from twisted.internet import defer import synapse.server import synapse.types from synapse.api.constants import EventTypes, Membership -from synapse.api.errors import AuthError, Codes, SynapseError +from synapse.api.errors import AuthError, Codes, HttpResponseException, SynapseError from synapse.types import RoomID, UserID from synapse.util.async_helpers import Linearizer from synapse.util.distributor import user_joined_room, user_left_room @@ -904,9 +904,22 @@ class RoomMemberHandler(object): } ) - data = yield self.simple_http_client.post_urlencoded_get_json( - is_url, invite_config - ) + try: + data = yield self.simple_http_client.post_json_get_json( + is_url, invite_config + ) + except HttpResponseException as e: + # Some identity servers may only support application/x-www-form-urlencoded + # types. This is especially true with old instances of Sydent, see + # https://github.com/matrix-org/sydent/pull/170 + logger.info( + "Failed to POST %s with JSON, falling back to urlencoded form: %s", + is_url, e, + ) + data = yield self.simple_http_client.post_urlencoded_get_json( + is_url, invite_config + ) + # TODO: Check for success token = data["token"] public_keys = data.get("public_keys", []) |