Skip to content
Snippets Groups Projects
Unverified Commit 9db24cc5 authored by Michael Telatynski's avatar Michael Telatynski Committed by GitHub
Browse files

Send unstable-prefixed room_type in store-invite IS API requests (#10435)

The room type is per MSC3288 to allow the identity-server to
change invitation wording based on whether the invitation is to
a room or a space.

The prefixed key will be replaced once MSC3288 is accepted
into the spec.
parent 684d19a1
No related branches found
No related tags found
No related merge requests found
Experimental support for [MSC3288](https://github.com/matrix-org/matrix-doc/pull/3288), sending `room_type` to the identity server for 3pid invites over the `/store-invite` API.
...@@ -824,6 +824,7 @@ class IdentityHandler(BaseHandler): ...@@ -824,6 +824,7 @@ class IdentityHandler(BaseHandler):
room_avatar_url: str, room_avatar_url: str,
room_join_rules: str, room_join_rules: str,
room_name: str, room_name: str,
room_type: Optional[str],
inviter_display_name: str, inviter_display_name: str,
inviter_avatar_url: str, inviter_avatar_url: str,
id_access_token: Optional[str] = None, id_access_token: Optional[str] = None,
...@@ -843,6 +844,7 @@ class IdentityHandler(BaseHandler): ...@@ -843,6 +844,7 @@ class IdentityHandler(BaseHandler):
notifications. notifications.
room_join_rules: The join rules of the email (e.g. "public"). room_join_rules: The join rules of the email (e.g. "public").
room_name: The m.room.name of the room. room_name: The m.room.name of the room.
room_type: The type of the room from its m.room.create event (e.g "m.space").
inviter_display_name: The current display name of the inviter_display_name: The current display name of the
inviter. inviter.
inviter_avatar_url: The URL of the inviter's avatar. inviter_avatar_url: The URL of the inviter's avatar.
...@@ -869,6 +871,10 @@ class IdentityHandler(BaseHandler): ...@@ -869,6 +871,10 @@ class IdentityHandler(BaseHandler):
"sender_display_name": inviter_display_name, "sender_display_name": inviter_display_name,
"sender_avatar_url": inviter_avatar_url, "sender_avatar_url": inviter_avatar_url,
} }
if room_type is not None:
invite_config["org.matrix.msc3288.room_type"] = room_type
# If a custom web client location is available, include it in the request. # If a custom web client location is available, include it in the request.
if self._web_client_location: if self._web_client_location:
invite_config["org.matrix.web_client_location"] = self._web_client_location invite_config["org.matrix.web_client_location"] = self._web_client_location
......
...@@ -19,7 +19,12 @@ from http import HTTPStatus ...@@ -19,7 +19,12 @@ from http import HTTPStatus
from typing import TYPE_CHECKING, Iterable, List, Optional, Set, Tuple from typing import TYPE_CHECKING, Iterable, List, Optional, Set, Tuple
from synapse import types from synapse import types
from synapse.api.constants import AccountDataTypes, EventTypes, Membership from synapse.api.constants import (
AccountDataTypes,
EventContentFields,
EventTypes,
Membership,
)
from synapse.api.errors import ( from synapse.api.errors import (
AuthError, AuthError,
Codes, Codes,
...@@ -1237,6 +1242,11 @@ class RoomMemberHandler(metaclass=abc.ABCMeta): ...@@ -1237,6 +1242,11 @@ class RoomMemberHandler(metaclass=abc.ABCMeta):
if room_name_event: if room_name_event:
room_name = room_name_event.content.get("name", "") room_name = room_name_event.content.get("name", "")
room_type = None
room_create_event = room_state.get((EventTypes.Create, ""))
if room_create_event:
room_type = room_create_event.content.get(EventContentFields.ROOM_TYPE)
room_join_rules = "" room_join_rules = ""
join_rules_event = room_state.get((EventTypes.JoinRules, "")) join_rules_event = room_state.get((EventTypes.JoinRules, ""))
if join_rules_event: if join_rules_event:
...@@ -1263,6 +1273,7 @@ class RoomMemberHandler(metaclass=abc.ABCMeta): ...@@ -1263,6 +1273,7 @@ class RoomMemberHandler(metaclass=abc.ABCMeta):
room_avatar_url=room_avatar_url, room_avatar_url=room_avatar_url,
room_join_rules=room_join_rules, room_join_rules=room_join_rules,
room_name=room_name, room_name=room_name,
room_type=room_type,
inviter_display_name=inviter_display_name, inviter_display_name=inviter_display_name,
inviter_avatar_url=inviter_avatar_url, inviter_avatar_url=inviter_avatar_url,
id_access_token=id_access_token, id_access_token=id_access_token,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment