diff --git a/changelog.d/375.feature b/changelog.d/375.feature
new file mode 100644
index 00000000..ef4d528f
--- /dev/null
+++ b/changelog.d/375.feature
@@ -0,0 +1 @@
+Experimental support for [MSC3288](https://github.com/matrix-org/matrix-doc/pull/3288), receiving `room_type` for 3pid invites over the `/store-invite` API and using it in Jinja templates for Space invites.
\ No newline at end of file
diff --git a/matrix_is_test/launcher.py b/matrix_is_test/launcher.py
index fecc5e05..cc1723c2 100644
--- a/matrix_is_test/launcher.py
+++ b/matrix_is_test/launcher.py
@@ -40,6 +40,7 @@
[email]
email.tlsmode = 0
email.invite.subject = %(sender_display_name)s has invited you to chat
+email.invite.subject_space = %(sender_display_name)s has invited you to a space
email.smtphost = localhost
email.from = Sydent Validation
Join the conversation. + href="%(web_client_location)s/#/room/%(room_id_forurl)s?email=%(to_forurl)s&signurl=https%%3A%%2F%%2Fmatrix.org%%2F_matrix%%2Fidentity%%2Fapi%%2Fv1%%2Fsign-ed25519%%3Ftoken%%3D%(token)s%%26private_key%%3D%(ephemeral_private_key)s&room_name=%(room_name_forurl)s&room_avatar_url=%(room_avatar_url_forurl)s&inviter_name=%(sender_display_name_forurl)s&guest_access_token=%(guest_access_token_forurl)s&guest_user_id=%(guest_user_id_forurl)s&room_type=%(room_type_forurl)s">Join the conversation.
Hi,
-{{ sender_display_name }} {{ bracketed_verified_sender }} has invited you into a room {{ bracketed_room_name }} on +
{{ sender_display_name }} {{ bracketed_verified_sender }} has invited you into a {% if room_type == "m.space" %}space{% else %}room{% endif %} {{ bracketed_room_name }} on Matrix. To join the conversation, either pick a Matrix client or use the single-click link below to join via Element (requires Chrome, @@ -116,7 +116,7 @@ or iOS or Android on mobile.)
Join the conversation. + href="{{ web_client_location }}/#/room/{{ room_id|urlencode }}?email={{ to|urlencode }}&signurl=https%3A%2F%2Fmatrix.org%2F_matrix%2Fidentity%2Fapi%2Fv1%2Fsign-ed25519%3Ftoken%3D{{ token|urlencode }}%26private_key%3D{{ ephemeral_private_key|urlencode }}&room_name={{ room_name|urlencode }}&room_avatar_url={{ room_avatar_url|urlencode }}&inviter_name={{ sender_display_name|urlencode }}&guest_access_token={{ guest_access_token|urlencode }}&guest_user_id={{ guest_user_id|urlencode }}&room_type={{ room_type|urlencode }}">Join the conversation.
Join the conversation. + href="%(web_client_location)s/#/room/%(room_id_forurl)s?email=%(to_forurl)s&signurl=https%%3A%%2F%%2Fvector.im%%2F_matrix%%2Fidentity%%2Fapi%%2Fv1%%2Fsign-ed25519%%3Ftoken%%3D%(token)s%%26private_key%%3D%(ephemeral_private_key)s&room_name=%(room_name_forurl)s&room_avatar_url=%(room_avatar_url_forurl)s&inviter_name=%(sender_display_name_forurl)s&guest_access_token=%(guest_access_token_forurl)s&guest_user_id=%(guest_user_id_forurl)s&room_type=%(room_type_forurl)s">Join the conversation.
Element is an open source collaboration app built on the Matrix.org diff --git a/res/vector-im/invite_template.eml.j2 b/res/vector-im/invite_template.eml.j2 index 3f3d99f1..95d0b586 100644 --- a/res/vector-im/invite_template.eml.j2 +++ b/res/vector-im/invite_template.eml.j2 @@ -13,11 +13,11 @@ Content-Disposition: inline Hi, -{{ sender_display_name|safe }} {{ bracketed_verified_sender|safe }}has invited you into a room +{{ sender_display_name|safe }} {{ bracketed_verified_sender|safe }}has invited you into a {% if room_type == "m.space" %}space{% else %}room{% endif %} {{ bracketed_room_name|safe }}on Element. To join the conversation please follow the link below. -{{ web_client_location }}/#/room/{{ room_id|urlencode }}?email={{ to|urlencode }}&signurl=https%3A%2F%2Fvector.im%2F_matrix%2Fidentity%2Fapi%2Fv1%2Fsign-ed25519%3Ftoken%3D{{ token|urlencode }}%26private_key%3D{{ ephemeral_private_key|urlencode }}&room_name={{ room_name|urlencode }}&room_avatar_url={{ room_avatar_url|urlencode }}&inviter_name={{ sender_display_name|urlencode }}&guest_access_token={{ guest_access_token|urlencode }}&guest_user_id={{ guest_user_id|urlencode }} +{{ web_client_location }}/#/room/{{ room_id|urlencode }}?email={{ to|urlencode }}&signurl=https%3A%2F%2Fvector.im%2F_matrix%2Fidentity%2Fapi%2Fv1%2Fsign-ed25519%3Ftoken%3D{{ token|urlencode }}%26private_key%3D{{ ephemeral_private_key|urlencode }}&room_name={{ room_name|urlencode }}&room_avatar_url={{ room_avatar_url|urlencode }}&inviter_name={{ sender_display_name|urlencode }}&guest_access_token={{ guest_access_token|urlencode }}&guest_user_id={{ guest_user_id|urlencode }}&room_type={{ room_type|urlencode }} Element is an open source collaboration app built on the Matrix.org open standard for interoperable communication: supporting group chat, @@ -124,11 +124,11 @@ pre, code {
Hi,
{{ sender_display_name }} {{ bracketed_verified_sender }} has invited you into a -room {{ bracketed_room_name }} on Element.
+{% if room_type == "m.space" %}space{% else %}room{% endif %} {{ bracketed_room_name }} on Element.Join the conversation. + href="{{ web_client_location }}/#/room/{{ room_id|urlencode }}?email={{ to|urlencode }}&signurl=https%3A%2F%2Fvector.im%2F_matrix%2Fidentity%2Fapi%2Fv1%2Fsign-ed25519%3Ftoken%3D{{ token|urlencode }}%26private_key%3D{{ ephemeral_private_key|urlencode }}&room_name={{ room_name|urlencode }}&room_avatar_url={{ room_avatar_url|urlencode }}&inviter_name={{ sender_display_name|urlencode }}&guest_access_token={{ guest_access_token|urlencode }}&guest_user_id={{ guest_user_id|urlencode }}&room_type={{ room_type|urlencode }}">Join the conversation.
Element is an open source collaboration app built on the Matrix.org
diff --git a/sydent/http/servlets/store_invite_servlet.py b/sydent/http/servlets/store_invite_servlet.py
index dd86e9f6..3277db96 100644
--- a/sydent/http/servlets/store_invite_servlet.py
+++ b/sydent/http/servlets/store_invite_servlet.py
@@ -125,6 +125,11 @@ def render_POST(self, request: Request) -> JsonDict:
for k in extra_substitutions:
substitutions.setdefault(k, "")
+ # MSC3288
+ substitutions["room_type"] = substitutions.pop(
+ "org.matrix.msc3288.room_type", ""
+ )
+
substitutions["bracketed_verified_sender"] = ""
if verified_sender:
substitutions["bracketed_verified_sender"] = "(%s) " % (verified_sender,)
@@ -140,7 +145,13 @@ def render_POST(self, request: Request) -> JsonDict:
)
subject_header = Header(
- self.sydent.cfg.get("email", "email.invite.subject", raw=True)
+ self.sydent.cfg.get(
+ "email",
+ "email.invite.subject_space"
+ if substitutions["room_type"] == "m.space"
+ else "email.invite.subject",
+ raw=True,
+ )
% substitutions,
"utf8",
)
diff --git a/sydent/sydent.py b/sydent/sydent.py
index 0f27657a..bf7e44d8 100644
--- a/sydent/sydent.py
+++ b/sydent/sydent.py
@@ -153,6 +153,7 @@
"email.from": "Sydent Validation