From 18101e85bb46d879ec7bb9e08d4a3fa25f5f19bc Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 20 Jul 2021 16:09:32 +0100 Subject: [PATCH 01/10] Initial room_type work, MSC pending --- matrix_is_test/launcher.py | 1 + res/matrix-org/invite_template.eml | 8 ++++---- res/vector-im/invite_template.eml | 8 ++++---- sydent/http/servlets/store_invite_servlet.py | 10 +++++++++- sydent/sydent.py | 1 + 5 files changed, 19 insertions(+), 9 deletions(-) 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 email.smtpport = 9925 diff --git a/res/matrix-org/invite_template.eml b/res/matrix-org/invite_template.eml index dfcd7216..24126613 100644 --- a/res/matrix-org/invite_template.eml +++ b/res/matrix-org/invite_template.eml @@ -13,13 +13,13 @@ Content-Disposition: inline Hi, -%(sender_display_name)s %(bracketed_verified_sender)shas invited you into a room +%(sender_display_name)s %(bracketed_verified_sender)shas invited you into a %(room_type_name)s %(bracketed_room_name)son Matrix. To join the conversation, either pick a Matrix client from https://matrix.org/docs/projects/try-matrix-now.html or use the single-click link below to join via Element (requires Chrome, Firefox, Safari, iOS or Android) -%(web_client_location)/#/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 +%(web_client_location)/#/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)s About Matrix: @@ -102,7 +102,7 @@ pre, code {

Hi,

-

%(sender_display_name_forhtml)s %(bracketed_verified_sender_forhtml)s has invited you into a room %(bracketed_room_name_forhtml)s on +

%(sender_display_name_forhtml)s %(bracketed_verified_sender_forhtml)s has invited you into a %(room_type_name)s %(bracketed_room_name_forhtml)s on Matrix. To join the conversation, either pick a Matrix client or use the single-click link below to join via Element (requires Chrome, @@ -113,7 +113,7 @@ or iOS or Android on mobile.)

Join the conversation. + href="https://app.element.io/#/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)s">Join the conversation.


diff --git a/res/vector-im/invite_template.eml b/res/vector-im/invite_template.eml index 6ee601f6..bdca5281 100644 --- a/res/vector-im/invite_template.eml +++ b/res/vector-im/invite_template.eml @@ -13,11 +13,11 @@ Content-Disposition: inline Hi, -%(sender_display_name)s %(bracketed_verified_sender)shas invited you into a room +%(sender_display_name)s %(bracketed_verified_sender)shas invited you into a %(room_type_name)s %(bracketed_room_name)son Element. To join the conversation please follow the link below. -%(web_client_location)/#/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 +%(web_client_location)/#/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)s 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_forhtml)s %(bracketed_verified_sender_forhtml)s has invited you into a -room %(bracketed_room_name_forhtml)s on Element.

+%(room_type_name)s %(bracketed_room_name_forhtml)s on Element.

Join the conversation. + href="https://app.element.io/#/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)s">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 9f05affa..07891fa1 100644 --- a/sydent/http/servlets/store_invite_servlet.py +++ b/sydent/http/servlets/store_invite_servlet.py @@ -122,6 +122,10 @@ def render_POST(self, request: Request) -> JsonDict: for k in extra_substitutions: substitutions.setdefault(k, "") + # MSCXXXX + substitutions["room_type"] = substitutions.pop("org.matrix.mscxxxx.room_type", "") + substitutions["room_type_name"] = "space" if substitutions["room_type"] == "m.space" else "room" + substitutions["bracketed_verified_sender"] = "" if verified_sender: substitutions["bracketed_verified_sender"] = "(%s) " % (verified_sender,) @@ -137,7 +141,11 @@ 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 e7579ca2..a4904347 100644 --- a/sydent/sydent.py +++ b/sydent/sydent.py @@ -152,6 +152,7 @@ "email.from": "Sydent Validation ", "email.subject": "Your Validation Token", "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.smtpport": "25", "email.smtpusername": "", From 04311039a11e5365aecf0f132ba9847f2f04bbb2 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 20 Jul 2021 17:23:34 +0100 Subject: [PATCH 02/10] Update reference to MSC3288 --- sydent/http/servlets/store_invite_servlet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sydent/http/servlets/store_invite_servlet.py b/sydent/http/servlets/store_invite_servlet.py index 07891fa1..b1aa4819 100644 --- a/sydent/http/servlets/store_invite_servlet.py +++ b/sydent/http/servlets/store_invite_servlet.py @@ -122,8 +122,8 @@ def render_POST(self, request: Request) -> JsonDict: for k in extra_substitutions: substitutions.setdefault(k, "") - # MSCXXXX - substitutions["room_type"] = substitutions.pop("org.matrix.mscxxxx.room_type", "") + # MSC3288 + substitutions["room_type"] = substitutions.pop("org.matrix.msc3288.room_type", "") substitutions["room_type_name"] = "space" if substitutions["room_type"] == "m.space" else "room" substitutions["bracketed_verified_sender"] = "" From ffd03c21e05978114c6c5f7356fbec547737e9fe Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 26 Jul 2021 13:17:45 +0100 Subject: [PATCH 03/10] delint --- sydent/http/servlets/store_invite_servlet.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sydent/http/servlets/store_invite_servlet.py b/sydent/http/servlets/store_invite_servlet.py index b1aa4819..775cc4d3 100644 --- a/sydent/http/servlets/store_invite_servlet.py +++ b/sydent/http/servlets/store_invite_servlet.py @@ -123,8 +123,12 @@ def render_POST(self, request: Request) -> JsonDict: substitutions.setdefault(k, "") # MSC3288 - substitutions["room_type"] = substitutions.pop("org.matrix.msc3288.room_type", "") - substitutions["room_type_name"] = "space" if substitutions["room_type"] == "m.space" else "room" + substitutions["room_type"] = substitutions.pop( + "org.matrix.msc3288.room_type", "" + ) + substitutions["room_type_name"] = ( + "space" if substitutions["room_type"] == "m.space" else "room" + ) substitutions["bracketed_verified_sender"] = "" if verified_sender: @@ -143,7 +147,9 @@ def render_POST(self, request: Request) -> JsonDict: subject_header = Header( self.sydent.cfg.get( "email", - "email.invite.subject_space" if substitutions["room_type"] == "m.space" else "email.invite.subject", + "email.invite.subject_space" + if substitutions["room_type"] == "m.space" + else "email.invite.subject", raw=True, ) % substitutions, From 83c85b73426d1ea5489d2aa2ee9ec8bfc1571881 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 26 Jul 2021 21:23:27 +0100 Subject: [PATCH 04/10] Make the stock templates actually valid python format strings --- res/matrix-org/invite_template.eml | 2 +- res/vector-im/invite_template.eml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/res/matrix-org/invite_template.eml b/res/matrix-org/invite_template.eml index 24126613..981bc35e 100644 --- a/res/matrix-org/invite_template.eml +++ b/res/matrix-org/invite_template.eml @@ -19,7 +19,7 @@ Matrix client from https://matrix.org/docs/projects/try-matrix-now.html or use the single-click link below to join via Element (requires Chrome, Firefox, Safari, iOS or Android) -%(web_client_location)/#/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)s +%(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)s About Matrix: diff --git a/res/vector-im/invite_template.eml b/res/vector-im/invite_template.eml index bdca5281..85f3a0fe 100644 --- a/res/vector-im/invite_template.eml +++ b/res/vector-im/invite_template.eml @@ -17,7 +17,7 @@ Hi, %(bracketed_room_name)son Element. To join the conversation please follow the link below. -%(web_client_location)/#/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)s +%(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)s Element is an open source collaboration app built on the Matrix.org open standard for interoperable communication: supporting group chat, From 3a65dae5f40b00613fa135d3678b692060ee6116 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 26 Jul 2021 21:26:31 +0100 Subject: [PATCH 05/10] add changelog entry --- changelog.d/375.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/375.feature diff --git a/changelog.d/375.feature b/changelog.d/375.feature new file mode 100644 index 00000000..2c145ae7 --- /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 in templates for Space invites. \ No newline at end of file From 90774cb2249d38e5a9095749e00a3bb001f566f5 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 30 Aug 2021 09:13:51 -0400 Subject: [PATCH 06/10] Update for changes from #376. --- res/matrix-org/invite_template.eml | 4 ++-- res/matrix-org/invite_template.eml.j2 | 8 ++++---- res/vector-im/invite_template.eml.j2 | 8 ++++---- sydent/http/servlets/store_invite_servlet.py | 3 --- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/res/matrix-org/invite_template.eml b/res/matrix-org/invite_template.eml index 981bc35e..e6cff14f 100644 --- a/res/matrix-org/invite_template.eml +++ b/res/matrix-org/invite_template.eml @@ -13,7 +13,7 @@ Content-Disposition: inline Hi, -%(sender_display_name)s %(bracketed_verified_sender)shas invited you into a %(room_type_name)s +%(sender_display_name)s %(bracketed_verified_sender)shas invited you into a room %(bracketed_room_name)son Matrix. To join the conversation, either pick a Matrix client from https://matrix.org/docs/projects/try-matrix-now.html or use the single-click link below to join via Element (requires Chrome, Firefox, @@ -102,7 +102,7 @@ pre, code {

Hi,

-

%(sender_display_name_forhtml)s %(bracketed_verified_sender_forhtml)s has invited you into a %(room_type_name)s %(bracketed_room_name_forhtml)s on +

%(sender_display_name_forhtml)s %(bracketed_verified_sender_forhtml)s has invited you into a room %(bracketed_room_name_forhtml)s on Matrix. To join the conversation, either pick a Matrix client or use the single-click link below to join via Element (requires Chrome, diff --git a/res/matrix-org/invite_template.eml.j2 b/res/matrix-org/invite_template.eml.j2 index 9fd23212..d830d49f 100644 --- a/res/matrix-org/invite_template.eml.j2 +++ b/res/matrix-org/invite_template.eml.j2 @@ -13,14 +13,14 @@ 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 Matrix. To join the conversation, either pick a Matrix client from https://matrix.org/docs/projects/try-matrix-now.html or use the single-click link below to join via Element (requires Chrome, Firefox, Safari, iOS or Android) -{{ 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 }} +{{ 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 }} About Matrix: @@ -105,7 +105,7 @@ pre, code {

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="https://app.element.io/#/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.


diff --git a/res/vector-im/invite_template.eml.j2 b/res/vector-im/invite_template.eml.j2 index d35a4342..1e4f0ab9 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="https://app.element.io/#/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 09d61c5d..3277db96 100644 --- a/sydent/http/servlets/store_invite_servlet.py +++ b/sydent/http/servlets/store_invite_servlet.py @@ -129,9 +129,6 @@ def render_POST(self, request: Request) -> JsonDict: substitutions["room_type"] = substitutions.pop( "org.matrix.msc3288.room_type", "" ) - substitutions["room_type_name"] = ( - "space" if substitutions["room_type"] == "m.space" else "room" - ) substitutions["bracketed_verified_sender"] = "" if verified_sender: From 5a15a17dc1f65d78cd9814f226858453b71dc655 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Mon, 30 Aug 2021 09:15:26 -0400 Subject: [PATCH 07/10] Revert another change. --- res/vector-im/invite_template.eml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/vector-im/invite_template.eml b/res/vector-im/invite_template.eml index 85f3a0fe..b344d4d0 100644 --- a/res/vector-im/invite_template.eml +++ b/res/vector-im/invite_template.eml @@ -13,7 +13,7 @@ Content-Disposition: inline Hi, -%(sender_display_name)s %(bracketed_verified_sender)shas invited you into a %(room_type_name)s +%(sender_display_name)s %(bracketed_verified_sender)shas invited you into a room %(bracketed_room_name)son Element. To join the conversation please follow the link below. @@ -124,7 +124,7 @@ pre, code {

Hi,

%(sender_display_name_forhtml)s %(bracketed_verified_sender_forhtml)s has invited you into a -%(room_type_name)s %(bracketed_room_name_forhtml)s on Element.

+room %(bracketed_room_name_forhtml)s on Element.

Date: Mon, 30 Aug 2021 09:27:33 -0400 Subject: [PATCH 08/10] Fix tests. --- tests/test_jinja_templates.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_jinja_templates.py b/tests/test_jinja_templates.py index 06ef612b..6736f913 100644 --- a/tests/test_jinja_templates.py +++ b/tests/test_jinja_templates.py @@ -51,6 +51,7 @@ def test_jinja_vector_invite(self): "token": "a_token", "ephemeral_private_key": "mystery_key", "web_client_location": "https://app.element.io", + "room_type": "", } templateFile = self.sydent.get_branded_template( @@ -90,7 +91,7 @@ def test_jinja_vector_invite(self): + urllib.parse.quote("mxc://example.org/s0meM3dia") + "&inviter_name=" + urllib.parse.quote("") - + "&guest_access_token=&guest_user_id=" + + "&guest_access_token=&guest_user_id=&room_type=" ) text = email_contents.splitlines() link = text[19] @@ -113,6 +114,7 @@ def test_jinja_matrix_invite(self): "token": "a_token", "ephemeral_private_key": "mystery_key", "web_client_location": "https://matrix.org", + "room_type": "", } templateFile = self.sydent.get_branded_template( @@ -152,7 +154,7 @@ def test_jinja_matrix_invite(self): + urllib.parse.quote("mxc://example.org/s0meM3dia") + "&inviter_name=" + urllib.parse.quote("") - + "&guest_access_token=&guest_user_id=" + + "&guest_access_token=&guest_user_id=&room_type=" ) text = email_contents.splitlines() link = text[22] From 17e703989f48102afce85e5e3d0d462818f2edeb Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 2 Sep 2021 12:57:11 -0400 Subject: [PATCH 09/10] Use the forurl versions. --- res/matrix-org/invite_template.eml | 4 ++-- res/vector-im/invite_template.eml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/res/matrix-org/invite_template.eml b/res/matrix-org/invite_template.eml index 117eb5ac..65ea0b50 100644 --- a/res/matrix-org/invite_template.eml +++ b/res/matrix-org/invite_template.eml @@ -19,7 +19,7 @@ Matrix client from https://matrix.org/docs/projects/try-matrix-now.html or use the single-click link below to join via Element (requires Chrome, Firefox, Safari, iOS or Android) -%(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)s +%(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 About Matrix: @@ -113,7 +113,7 @@ or iOS or Android on mobile.)

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.


diff --git a/res/vector-im/invite_template.eml b/res/vector-im/invite_template.eml index c6cd4694..57cc8b49 100644 --- a/res/vector-im/invite_template.eml +++ b/res/vector-im/invite_template.eml @@ -17,7 +17,7 @@ Hi, %(bracketed_room_name)son Element. To join the conversation please follow the link below. -%(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)s +%(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 Element is an open source collaboration app built on the Matrix.org open standard for interoperable communication: supporting group chat, @@ -128,7 +128,7 @@ room %(bracketed_room_name_forhtml)s on Element.

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 From 22ca94762df7337a80fdb4bfa9b192797b491f16 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Fri, 3 Sep 2021 07:31:05 -0400 Subject: [PATCH 10/10] Update changelog. --- changelog.d/375.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/375.feature b/changelog.d/375.feature index 2c145ae7..ef4d528f 100644 --- a/changelog.d/375.feature +++ b/changelog.d/375.feature @@ -1 +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 in templates for Space invites. \ No newline at end of file +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