Allow configuring the Riot URL used in notification emails
The URLs used for notification emails were hardcoded to use either matrix.to or vector.im; but for self-hosted setups where Riot is also self-hosted it may be desirable to allow configuring an alternative Riot URL. Fixes #1809. Signed-off-by: Adrian Perez de Castro <aperez@igalia.com>
This commit is contained in:
parent
641ccdbb14
commit
a3e4a198e3
|
@ -68,6 +68,9 @@ class EmailConfig(Config):
|
||||||
self.email_notif_for_new_users = email_config.get(
|
self.email_notif_for_new_users = email_config.get(
|
||||||
"notif_for_new_users", True
|
"notif_for_new_users", True
|
||||||
)
|
)
|
||||||
|
self.email_riot_base_url = email_config.get(
|
||||||
|
"riot_base_url", None
|
||||||
|
)
|
||||||
if "app_name" in email_config:
|
if "app_name" in email_config:
|
||||||
self.email_app_name = email_config["app_name"]
|
self.email_app_name = email_config["app_name"]
|
||||||
else:
|
else:
|
||||||
|
@ -85,6 +88,9 @@ class EmailConfig(Config):
|
||||||
def default_config(self, config_dir_path, server_name, **kwargs):
|
def default_config(self, config_dir_path, server_name, **kwargs):
|
||||||
return """
|
return """
|
||||||
# Enable sending emails for notification events
|
# Enable sending emails for notification events
|
||||||
|
# Defining a custom URL for Riot is only needed if email notifications
|
||||||
|
# should contain links to a self-hosted installation of Riot; when set
|
||||||
|
# the "app_name" setting is ignored.
|
||||||
#email:
|
#email:
|
||||||
# enable_notifs: false
|
# enable_notifs: false
|
||||||
# smtp_host: "localhost"
|
# smtp_host: "localhost"
|
||||||
|
@ -95,4 +101,5 @@ class EmailConfig(Config):
|
||||||
# notif_template_html: notif_mail.html
|
# notif_template_html: notif_mail.html
|
||||||
# notif_template_text: notif_mail.txt
|
# notif_template_text: notif_mail.txt
|
||||||
# notif_for_new_users: True
|
# notif_for_new_users: True
|
||||||
|
# riot_base_url: "http://localhost/riot"
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -439,15 +439,23 @@ class Mailer(object):
|
||||||
})
|
})
|
||||||
|
|
||||||
def make_room_link(self, room_id):
|
def make_room_link(self, room_id):
|
||||||
# need /beta for Universal Links to work on iOS
|
if self.hs.config.email_riot_base_url:
|
||||||
if self.app_name == "Vector":
|
base_url = self.hs.config.email_riot_base_url
|
||||||
return "https://vector.im/beta/#/room/%s" % (room_id,)
|
elif self.app_name == "Vector":
|
||||||
|
# need /beta for Universal Links to work on iOS
|
||||||
|
base_url = "https://vector.im/beta/#/room"
|
||||||
else:
|
else:
|
||||||
return "https://matrix.to/#/%s" % (room_id,)
|
base_url = "https://matrix.to/#"
|
||||||
|
return "%s/%s" % (base_url, room_id)
|
||||||
|
|
||||||
def make_notif_link(self, notif):
|
def make_notif_link(self, notif):
|
||||||
# need /beta for Universal Links to work on iOS
|
if self.hs.config.email_riot_base_url:
|
||||||
if self.app_name == "Vector":
|
return "%s/#/room/%s/%s" % (
|
||||||
|
self.hs.config.email_riot_base_url,
|
||||||
|
notif['room_id'], notif['event_id']
|
||||||
|
)
|
||||||
|
elif self.app_name == "Vector":
|
||||||
|
# need /beta for Universal Links to work on iOS
|
||||||
return "https://vector.im/beta/#/room/%s/%s" % (
|
return "https://vector.im/beta/#/room/%s/%s" % (
|
||||||
notif['room_id'], notif['event_id']
|
notif['room_id'], notif['event_id']
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue