💄 — Add link to task view in notifications

This commit is contained in:
Luc Didry 2023-12-07 07:33:22 +01:00
parent 04aaa3d8d7
commit 39eace6152
No known key found for this signature in database
GPG key ID: EA868E12D0257E3C
2 changed files with 7 additions and 3 deletions

View file

@ -13,18 +13,22 @@ from argos.schemas.config import Config, Mail, GotifyUrl
# XXX Implement mail alerts https://framagit.org/framasoft/framaspace/argos/-/issues/15
# XXX Implement gotify alerts https://framagit.org/framasoft/framaspace/argos/-/issues/16
def handle_alert(config: Config, result, task, severity):
def handle_alert(config: Config, result, task, severity, request):
"""Dispatch alert through configured alert channels"""
msg = f"task={task.id}, status={result.status}, {severity=}"
logger.error("Alerting stub: %s", msg)
if config.general.mail is not None or config.general.gotify is not None:
if config.general.mail is not None or \
config.general.gotify is not None:
subject = f"{urlparse(task.url).netloc}: status {severity}"
msg = f"""\
URL: {task.url}
Check: {task.check}
Status: {severity}
Time: {result.submitted_at}
See results of task on {request.url_for('get_task_results', task_id=task.id)}
"""
if config.general.mail is not None:

View file

@ -59,7 +59,7 @@ async def create_results(
# Dont create an alert if the severity has not changed
if last_severity != severity:
handle_alert(config, result, task, severity)
handle_alert(config, result, task, severity, request)
db_results.append(result)
db.commit()