mirror of
https://framagit.org/framasoft/framaspace/argos.git
synced 2025-04-28 18:02:41 +02:00
💄 — Add link to task view in notifications
This commit is contained in:
parent
04aaa3d8d7
commit
39eace6152
2 changed files with 7 additions and 3 deletions
|
@ -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:
|
||||
|
|
|
@ -59,7 +59,7 @@ async def create_results(
|
|||
|
||||
# Don’t 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()
|
||||
|
|
Loading…
Reference in a new issue