Use application/json when querying the IS's /store-invite endpoint

This commit is contained in:
Brendan Abolivier 2019-07-08 14:19:39 +01:00
parent 555b6fa0d5
commit 1a807dfe68
No known key found for this signature in database
GPG Key ID: 1E015C145F1916CD

View File

@ -29,7 +29,7 @@ from twisted.internet import defer
import synapse.server import synapse.server
import synapse.types import synapse.types
from synapse.api.constants import EventTypes, Membership 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.types import RoomID, UserID
from synapse.util.async_helpers import Linearizer from synapse.util.async_helpers import Linearizer
from synapse.util.distributor import user_joined_room, user_left_room from synapse.util.distributor import user_joined_room, user_left_room
@ -904,9 +904,22 @@ class RoomMemberHandler(object):
} }
) )
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( data = yield self.simple_http_client.post_urlencoded_get_json(
is_url, invite_config is_url, invite_config
) )
# TODO: Check for success # TODO: Check for success
token = data["token"] token = data["token"]
public_keys = data.get("public_keys", []) public_keys = data.get("public_keys", [])