misc: allow an "empty" value (single dash) for trace emails (#88841)
gitea/passerelle/pipeline/head This commit looks good
Details
gitea/passerelle/pipeline/head This commit looks good
Details
This commit is contained in:
parent
96c1e49e23
commit
75fb200762
|
@ -14,7 +14,8 @@ class Migration(migrations.Migration):
|
|||
name='trace_emails',
|
||||
field=models.TextField(
|
||||
blank=True,
|
||||
help_text='One address per line (empty for site administrators)',
|
||||
help_text='One address per line (empty for site administrators), '
|
||||
'a single dash "-" for no mail at all)',
|
||||
verbose_name='Emails to receive error and critical traces',
|
||||
),
|
||||
),
|
||||
|
|
|
@ -734,7 +734,9 @@ class LoggingParameters(models.Model):
|
|||
)
|
||||
trace_emails = models.TextField(
|
||||
verbose_name=_('Emails to receive error and critical traces'),
|
||||
help_text=_('One address per line (empty for site administrators)'),
|
||||
help_text=_(
|
||||
'One address per line (empty for site administrators, a single dash "-" for no mail at all)'
|
||||
),
|
||||
blank=True,
|
||||
)
|
||||
requests_max_size = models.PositiveIntegerField(
|
||||
|
@ -1072,7 +1074,9 @@ class ProxyLogger:
|
|||
|
||||
admins = settings.ADMINS
|
||||
logging_parameters = self.connector.logging_parameters
|
||||
if logging_parameters.trace_emails:
|
||||
if logging_parameters.trace_emails == '-':
|
||||
admins = []
|
||||
elif logging_parameters.trace_emails:
|
||||
admins = [('', x) for x in logging_parameters.trace_emails.splitlines()]
|
||||
with override_settings(ADMINS=admins):
|
||||
getattr(self._logger, levelname.lower())(message, *args, **kwargs)
|
||||
|
|
|
@ -134,6 +134,17 @@ def test_trace_emails(app, settings, dummy_csv_datasource, email_handler, mailou
|
|||
assert mailoutbox[0].to == ['admin@example.net']
|
||||
assert mailoutbox[idx].to == ['john.doe@example.net']
|
||||
|
||||
logging_parameters.trace_emails = '-'
|
||||
logging_parameters.save()
|
||||
app.get(
|
||||
generic_endpoint_url(
|
||||
connector='csvdatasource', endpoint='query/dummy-query/', slug=dummy_csv_datasource.slug
|
||||
),
|
||||
status=500,
|
||||
)
|
||||
|
||||
assert len(mailoutbox) == 2 # no new mail
|
||||
|
||||
|
||||
def test_check_status_no_traceback_email(db, settings, email_handler, mailoutbox):
|
||||
settings.ADMINS = [('admin', 'admin@example.net')]
|
||||
|
|
Loading…
Reference in New Issue