Skip to content

Commit

Permalink
Merge pull request #10956 from ic4f/dev_issue10846
Browse files Browse the repository at this point in the history
Use "email_from" value from schema for tool error report email
  • Loading branch information
jdavcs authored Dec 17, 2020
2 parents fb2302e + 6157149 commit 2cf41d7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 29 deletions.
18 changes: 14 additions & 4 deletions doc/source/admin/galaxy_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]> 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 <[email protected]>. If
not configured, '<galaxy-no-reply@HOSTNAME>' will be used.
:Default: ``None``
:Type: str

Expand Down Expand Up @@ -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``
~~~~~~~~~~~~~~~
Expand Down
11 changes: 7 additions & 4 deletions lib/galaxy/config/sample/galaxy.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]> 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 <[email protected]>. If
# not configured, '<galaxy-no-reply@HOSTNAME>' will be used.
#email_from: null

# URL of the support resource for the galaxy instance. Used in
Expand Down Expand Up @@ -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/

Expand Down
9 changes: 5 additions & 4 deletions lib/galaxy/security/validate_user_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@

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):
Expand Down
24 changes: 10 additions & 14 deletions lib/galaxy/tools/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
util,
web
)
from galaxy.security.validate_user_input import validate_email_str
from galaxy.util import unicodify

error_report_template = """
Expand Down Expand Up @@ -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")

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
to = self.app.config.error_email_to
assert to, ValueError("Error reporting has been disabled for this Galaxy instance")

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)
6 changes: 3 additions & 3 deletions lib/galaxy/webapps/galaxy/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
account activations, workflow step notifications, password resets, and
tool error reports. We recommend using a string in the following format:
Galaxy Project <[email protected]>.
If not configured, '<galaxy-no-reply@HOSTNAME>' will be used.
instance_resource_url:
Expand Down

0 comments on commit 2cf41d7

Please sign in to comment.