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

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

Merged
merged 11 commits into from
Aug 4, 2021
1 change: 1 addition & 0 deletions changelog.d/10435.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
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.
3 changes: 3 additions & 0 deletions synapse/handlers/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ async def ask_id_server_for_third_party_invite(
room_avatar_url: str,
room_join_rules: str,
room_name: str,
room_type: str,
inviter_display_name: str,
inviter_avatar_url: str,
id_access_token: Optional[str] = None,
Expand All @@ -843,6 +844,7 @@ async def ask_id_server_for_third_party_invite(
notifications.
room_join_rules: The join rules of the email (e.g. "public").
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.
inviter_avatar_url: The URL of the inviter's avatar.
Expand All @@ -868,6 +870,7 @@ async def ask_id_server_for_third_party_invite(
"sender": inviter_user_id,
"sender_display_name": inviter_display_name,
"sender_avatar_url": inviter_avatar_url,
"org.matrix.msc3288.room_type": room_type, # MSC3288
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
}
# If a custom web client location is available, include it in the request.
if self._web_client_location:
Expand Down
13 changes: 12 additions & 1 deletion synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple

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 (
AuthError,
Codes,
Expand Down Expand Up @@ -1138,6 +1143,11 @@ async def _make_and_store_3pid_invite(
if room_name_event:
room_name = room_name_event.content.get("name", "")

room_type = ""
room_create_event = room_state.get((EventTypes.Create, ""))
if room_create_event:
room_type = room_create_event.content.get(EventContentFields.ROOM_TYPE, "")
t3chguy marked this conversation as resolved.
Show resolved Hide resolved

room_join_rules = ""
join_rules_event = room_state.get((EventTypes.JoinRules, ""))
if join_rules_event:
Expand All @@ -1164,6 +1174,7 @@ async def _make_and_store_3pid_invite(
room_avatar_url=room_avatar_url,
room_join_rules=room_join_rules,
room_name=room_name,
room_type=room_type,
inviter_display_name=inviter_display_name,
inviter_avatar_url=inviter_avatar_url,
id_access_token=id_access_token,
Expand Down