fix(alerts): tell informational alerts from real stand-downs by type
This commit is contained in:
+22
-2
@@ -5,6 +5,18 @@ from typing import Any
|
||||
|
||||
LEVEL_ICON = {"OK": "✅", "WARNING": "🟠", "CRITICAL": "🔴"}
|
||||
|
||||
INFORMATIONAL = frozenset(
|
||||
{
|
||||
"StackImageUpdateAvailable",
|
||||
"DeploymentImageUpdateAvailable",
|
||||
"StackAutoUpdated",
|
||||
"DeploymentAutoUpdated",
|
||||
"ScheduleRun",
|
||||
"Test",
|
||||
"Custom",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def _gb(value: Any) -> str: # noqa: ANN401
|
||||
try:
|
||||
@@ -87,12 +99,20 @@ def _describe(kind: str, d: dict) -> tuple[str, list[str]]: # noqa: C901, PLR09
|
||||
|
||||
def format_alert(payload: dict) -> str:
|
||||
level = str(payload.get("level", "")).upper()
|
||||
resolved = bool(payload.get("resolved")) or level == "OK"
|
||||
data = payload.get("data") or {}
|
||||
kind = str(data.get("type") or "Unknown")
|
||||
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 {})
|
||||
|
||||
if resolved:
|
||||
|
||||
Reference in New Issue
Block a user