Merge pull request #10956 from ic4f/dev_issue10846

Use "email_from" value from schema for tool error report email
This commit is contained in:
Sergey Golitsynskiy
2020-12-17 15:23:30 -05:00
committed by GitHub
5 changed files with 38 additions and 28 deletions
+14 -4
View File
@@ -1282,10 +1282,10 @@
:Description:
Email address to use in the 'From' field when sending emails for
account activations, workflow step notifications and password
resets. We recommend using string in the following format: Galaxy
Project <galaxy-no-reply@example.com> If not configured,
'<galaxy-no-reply@HOSTNAME>' will be used.
account activations, workflow step notifications, password resets,
and tool error reports. We recommend using a string in the
following format: Galaxy Project <galaxy-no-reply@example.com>. If
not configured, '<galaxy-no-reply@HOSTNAME>' will be used.
:Default: ``None``
:Type: str
@@ -1734,6 +1734,16 @@
:Type: str
~~~~~~~~~~~~~
``quota_url``
~~~~~~~~~~~~~
:Description:
The URL linked for quota information in the UI.
:Default: ``https://galaxyproject.org/support/account-quotas/``
:Type: str
~~~~~~~~~~~~~~~
``support_url``
~~~~~~~~~~~~~~~
+7 -4
View File
@@ -723,10 +723,10 @@ galaxy:
#error_email_to: null
# Email address to use in the 'From' field when sending emails for
# account activations, workflow step notifications and password
# resets. We recommend using string in the following format: Galaxy
# Project <galaxy-no-reply@example.com> If not configured,
# '<galaxy-no-reply@HOSTNAME>' will be used.
# account activations, workflow step notifications, password resets,
# and tool error reports. We recommend using a string in the
# following format: Galaxy Project <galaxy-no-reply@example.com>. If
# not configured, '<galaxy-no-reply@HOSTNAME>' will be used.
#email_from: null
# URL of the support resource for the galaxy instance. Used in
@@ -928,6 +928,9 @@ galaxy:
# The URL linked by the "Wiki" link in the "Help" menu.
#wiki_url: https://galaxyproject.org/
# The URL linked for quota information in the UI.
#quota_url: https://galaxyproject.org/support/account-quotas/
# The URL linked by the "Support" link in the "Help" menu.
#support_url: https://galaxyproject.org/support/
+5 -4
View File
@@ -28,12 +28,13 @@ PASSWORD_MIN_LEN = 6
def validate_email_str(email):
"""Validates a string containing an email address."""
message = ''
if not email:
return "No email address was provided."
if not(VALID_EMAIL_RE.match(email)):
message = "The format of the email address is not correct."
return "The format of the email address is not correct."
elif len(email) > EMAIL_MAX_LEN:
message = "Email address cannot be more than %d characters in length." % EMAIL_MAX_LEN
return message
return "Email address cannot be more than %d characters in length." % EMAIL_MAX_LEN
return ""
def validate_password_str(password):
+9 -13
View File
@@ -10,6 +10,7 @@ from galaxy import (
util,
web
)
from galaxy.security.validate_user_input import validate_email_str
from galaxy.util import unicodify
error_report_template = """
@@ -237,23 +238,18 @@ class EmailErrorReporter(ErrorReporter):
def _send_report(self, user, email=None, message=None, **kwd):
smtp_server = self.app.config.smtp_server
assert smtp_server, ValueError("Mail is not configured for this Galaxy instance")
to_address = self.app.config.error_email_to
assert to_address, ValueError("Error reporting has been disabled for this Galaxy instance")
to = self.app.config.error_email_to
assert to, ValueError("Error reporting has been disabled for this Galaxy instance")
frm = to_address
# Check email a bit
email = email or ''
email = email.strip()
parts = email.split()
if len(parts) == 1 and len(email) > 0 and self._can_access_dataset(user):
to = to_address + ", " + email
else:
to = to_address
frm = self.app.config.email_from
error_msg = validate_email_str(email)
if not error_msg and self._can_access_dataset(user):
to += ', ' + email.strip()
subject = "Galaxy tool error report from %s" % email
try:
subject = "{} ({})".format(subject, self.app.toolbox.get_tool(self.job.tool_id, self.job.tool_version).old_id)
subject = "{} ({})".format(
subject, self.app.toolbox.get_tool(self.job.tool_id, self.job.tool_version).old_id)
except Exception:
pass
# Send it
return util.send_mail(frm, to, subject, self.report, self.app.config, html=self.html_report)
+3 -3
View File
@@ -922,9 +922,9 @@ mapping:
required: false
desc: |
Email address to use in the 'From' field when sending emails for
account activations, workflow step notifications and password resets.
We recommend using string in the following format:
Galaxy Project <galaxy-no-reply@example.com>
account activations, workflow step notifications, password resets, and
tool error reports. We recommend using a string in the following format:
Galaxy Project <galaxy-no-reply@example.com>.
If not configured, '<galaxy-no-reply@HOSTNAME>' will be used.
instance_resource_url: