From 1e9d3d707f32a53a28ad343c189d179e27a7cfb6 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Thu, 6 Apr 2017 18:23:52 +0100 Subject: [PATCH] Add a configurable fallback URL for emails This will allow the fixing of an issue where changes created by things using the API directly, such as the Gerrit plugin, cause broken URLs in notification emails. Change-Id: Ibad10fa35b7acaaa59cbb28b0960571480f80552 --- etc/storyboard.conf.sample | 3 +++ storyboard/plugin/email/__init__.py | 3 +++ storyboard/plugin/email/workers.py | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/etc/storyboard.conf.sample b/etc/storyboard.conf.sample index df30bfcc..eb2c149b 100644 --- a/etc/storyboard.conf.sample +++ b/etc/storyboard.conf.sample @@ -168,6 +168,9 @@ lock_path = $state_path/lock # The email address of the Reply-To header (optional). # reply_to = +# The default url base to use in emails, if Referer is not set. +# default_url = https://storyboard.openstack.org/ + # The SMTP server to use. # smtp_host = localhost diff --git a/storyboard/plugin/email/__init__.py b/storyboard/plugin/email/__init__.py index 1d3b54b6..415fb140 100644 --- a/storyboard/plugin/email/__init__.py +++ b/storyboard/plugin/email/__init__.py @@ -33,6 +33,9 @@ PLUGIN_OPTS = [ cfg.StrOpt("reply_to", default=None, help="The email address of the Reply-To header (optional)."), + cfg.StrOpt("default_url", + default=None, + help="The default/fallback url base to use in emails."), cfg.StrOpt("smtp_host", default='localhost', help="The SMTP server to use."), diff --git a/storyboard/plugin/email/workers.py b/storyboard/plugin/email/workers.py index 444113a8..b1bab7ac 100644 --- a/storyboard/plugin/email/workers.py +++ b/storyboard/plugin/email/workers.py @@ -282,6 +282,10 @@ class SubscriptionEmailWorker(EmailWorkerBase): if email_config.reply_to: factory.add_header('Reply-To', email_config.reply_to) + # If there is a fallback URL configured, use it if needed + if email_config.default_url and url is None: + url = email_config.default_url + # Resolve the resource instance resource_instance = self.resolve_resource_by_name(session, resource, resource_id)