mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
✨ — Use alerts config in handle_alert
This commit is contained in:
parent
39eace6152
commit
2ab9afabc9
1 changed files with 10 additions and 4 deletions
|
@ -15,8 +15,12 @@ from argos.schemas.config import Config, Mail, GotifyUrl
|
||||||
|
|
||||||
def handle_alert(config: Config, result, task, severity, request):
|
def handle_alert(config: Config, result, task, severity, request):
|
||||||
"""Dispatch alert through configured alert channels"""
|
"""Dispatch alert through configured alert channels"""
|
||||||
msg = f"task={task.id}, status={result.status}, {severity=}"
|
|
||||||
logger.error("Alerting stub: %s", msg)
|
if 'local' in getattr(config.general.alerts, severity):
|
||||||
|
logger.error("Alerting stub: task=%i, status=%s, severity=%s",
|
||||||
|
task.id,
|
||||||
|
result.status,
|
||||||
|
severity)
|
||||||
|
|
||||||
if config.general.mail is not None or \
|
if config.general.mail is not None or \
|
||||||
config.general.gotify is not None:
|
config.general.gotify is not None:
|
||||||
|
@ -31,9 +35,11 @@ Time: {result.submitted_at}
|
||||||
See results of task on {request.url_for('get_task_results', task_id=task.id)}
|
See results of task on {request.url_for('get_task_results', task_id=task.id)}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if config.general.mail is not None:
|
if config.general.mail is not None and \
|
||||||
|
'mail' in getattr(config.general.alerts, severity):
|
||||||
notify_by_mail(subject, msg, config.general.mail)
|
notify_by_mail(subject, msg, config.general.mail)
|
||||||
if config.general.gotify is not None:
|
if config.general.gotify is not None and \
|
||||||
|
'gotify' in getattr(config.general.alerts, severity):
|
||||||
notify_with_gotify(subject, msg, severity, config.general.gotify)
|
notify_with_gotify(subject, msg, severity, config.general.gotify)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue