fix(alerts): tell informational alerts from real stand-downs by type

This commit is contained in:
hh
2026-07-23 05:04:14 +02:00
parent a6968ebbe6
commit 2cd3e64cee
+22 -2
View File
@@ -5,6 +5,18 @@ from typing import Any
LEVEL_ICON = {"OK": "", "WARNING": "🟠", "CRITICAL": "🔴"} LEVEL_ICON = {"OK": "", "WARNING": "🟠", "CRITICAL": "🔴"}
INFORMATIONAL = frozenset(
{
"StackImageUpdateAvailable",
"DeploymentImageUpdateAvailable",
"StackAutoUpdated",
"DeploymentAutoUpdated",
"ScheduleRun",
"Test",
"Custom",
}
)
def _gb(value: Any) -> str: # noqa: ANN401 def _gb(value: Any) -> str: # noqa: ANN401
try: try:
@@ -87,12 +99,20 @@ def _describe(kind: str, d: dict) -> tuple[str, list[str]]: # noqa: C901, PLR09
def format_alert(payload: dict) -> str: def format_alert(payload: dict) -> str:
level = str(payload.get("level", "")).upper() level = str(payload.get("level", "")).upper()
resolved = bool(payload.get("resolved")) or level == "OK"
data = payload.get("data") or {} data = payload.get("data") or {}
kind = str(data.get("type") or "Unknown") kind = str(data.get("type") or "Unknown")
inner = data.get("data") or {} inner = data.get("data") or {}
icon = "" if resolved else LEVEL_ICON.get(level, "🔔") informational = kind in INFORMATIONAL
resolved = bool(payload.get("resolved")) and not informational
if informational:
icon = ""
elif resolved:
icon = ""
else:
icon = LEVEL_ICON.get(level, "🔔")
title, details = _describe(kind, inner if isinstance(inner, dict) else {}) title, details = _describe(kind, inner if isinstance(inner, dict) else {})
if resolved: if resolved: