Skip to content
Snippets Groups Projects
Unverified Commit 56e00ca8 authored by Patrick Cloke's avatar Patrick Cloke Committed by GitHub
Browse files

Send the location of the web client to the IS when inviting via 3PIDs. (#8930)

Adds a new setting `email.invite_client_location` which, if defined, is
passed to the identity server during invites.
parent d781a81e
No related branches found
No related tags found
No related merge requests found
Add an `email.invite_client_location` configuration option to send a web client location to the invite endpoint on the identity server which allows customisation of the email template.
...@@ -2149,6 +2149,12 @@ email: ...@@ -2149,6 +2149,12 @@ email:
# #
#validation_token_lifetime: 15m #validation_token_lifetime: 15m
# The web client location to direct users to during an invite. This is passed
# to the identity server as the org.matrix.web_client_location key. Defaults
# to unset, giving no guidance to the identity server.
#
#invite_client_location: https://app.element.io
# Directory in which Synapse will try to find the template files below. # Directory in which Synapse will try to find the template files below.
# If not set, or the files named below are not found within the template # If not set, or the files named below are not found within the template
# directory, default templates from within the Synapse package will be used. # directory, default templates from within the Synapse package will be used.
......
...@@ -322,6 +322,22 @@ class EmailConfig(Config): ...@@ -322,6 +322,22 @@ class EmailConfig(Config):
self.email_subjects = EmailSubjectConfig(**subjects) self.email_subjects = EmailSubjectConfig(**subjects)
# The invite client location should be a HTTP(S) URL or None.
self.invite_client_location = email_config.get("invite_client_location") or None
if self.invite_client_location:
if not isinstance(self.invite_client_location, str):
raise ConfigError(
"Config option email.invite_client_location must be type str"
)
if not (
self.invite_client_location.startswith("http://")
or self.invite_client_location.startswith("https://")
):
raise ConfigError(
"Config option email.invite_client_location must be a http or https URL",
path=("email", "invite_client_location"),
)
def generate_config_section(self, config_dir_path, server_name, **kwargs): def generate_config_section(self, config_dir_path, server_name, **kwargs):
return ( return (
"""\ """\
...@@ -389,6 +405,12 @@ class EmailConfig(Config): ...@@ -389,6 +405,12 @@ class EmailConfig(Config):
# #
#validation_token_lifetime: 15m #validation_token_lifetime: 15m
# The web client location to direct users to during an invite. This is passed
# to the identity server as the org.matrix.web_client_location key. Defaults
# to unset, giving no guidance to the identity server.
#
#invite_client_location: https://app.element.io
# Directory in which Synapse will try to find the template files below. # Directory in which Synapse will try to find the template files below.
# If not set, or the files named below are not found within the template # If not set, or the files named below are not found within the template
# directory, default templates from within the Synapse package will be used. # directory, default templates from within the Synapse package will be used.
......
...@@ -55,6 +55,8 @@ class IdentityHandler(BaseHandler): ...@@ -55,6 +55,8 @@ class IdentityHandler(BaseHandler):
self.federation_http_client = hs.get_federation_http_client() self.federation_http_client = hs.get_federation_http_client()
self.hs = hs self.hs = hs
self._web_client_location = hs.config.invite_client_location
async def threepid_from_creds( async def threepid_from_creds(
self, id_server: str, creds: Dict[str, str] self, id_server: str, creds: Dict[str, str]
) -> Optional[JsonDict]: ) -> Optional[JsonDict]:
...@@ -803,6 +805,9 @@ class IdentityHandler(BaseHandler): ...@@ -803,6 +805,9 @@ 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 a custom web client location is available, include it in the request.
if self._web_client_location:
invite_config["org.matrix.web_client_location"] = self._web_client_location
# Add the identity service access token to the JSON body and use the v2 # Add the identity service access token to the JSON body and use the v2
# Identity Service endpoints if id_access_token is present # Identity Service endpoints if id_access_token is present
......
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