Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 65434da

Browse files
authored
Merge pull request #5638 from matrix-org/babolivier/invite-json
Use JSON when querying the IS's /store-invite endpoint
2 parents 7b3bc75 + 57eacee commit 65434da

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

changelog.d/5638.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix requests to the `/store_invite` endpoint of identity servers being sent in the wrong format.

synapse/handlers/room_member.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import synapse.server
3030
import synapse.types
3131
from synapse.api.constants import EventTypes, Membership
32-
from synapse.api.errors import AuthError, Codes, SynapseError
32+
from synapse.api.errors import AuthError, Codes, HttpResponseException, SynapseError
3333
from synapse.types import RoomID, UserID
3434
from synapse.util.async_helpers import Linearizer
3535
from synapse.util.distributor import user_joined_room, user_left_room
@@ -872,9 +872,23 @@ def _ask_id_server_for_third_party_invite(
872872
"sender_avatar_url": inviter_avatar_url,
873873
}
874874

875-
data = yield self.simple_http_client.post_urlencoded_get_json(
876-
is_url, invite_config
877-
)
875+
try:
876+
data = yield self.simple_http_client.post_json_get_json(
877+
is_url, invite_config
878+
)
879+
except HttpResponseException as e:
880+
# Some identity servers may only support application/x-www-form-urlencoded
881+
# types. This is especially true with old instances of Sydent, see
882+
# https://github.com/matrix-org/sydent/pull/170
883+
logger.info(
884+
"Failed to POST %s with JSON, falling back to urlencoded form: %s",
885+
is_url,
886+
e,
887+
)
888+
data = yield self.simple_http_client.post_urlencoded_get_json(
889+
is_url, invite_config
890+
)
891+
878892
# TODO: Check for success
879893
token = data["token"]
880894
public_keys = data.get("public_keys", [])

0 commit comments

Comments
 (0)