ligbox-ops-platform/api/app/agents/notify.py
Ligbox Spec Hub 3a2c64834b Initial import: ligbox-ops-platform + specs + LAPTOP + obsidian merge (CT130)
Source: VM122 /opt + obsidian-infra + LAPTOP
Hub: CT130 spec-hub 10.10.10.130
2026-06-19 17:26:41 +00:00

24 lines
975 B
Python

"""Alerts Advisor — Spec 029."""
from __future__ import annotations
import os, urllib.request
from app import mail_notify
NTFY = os.getenv("DESK_OPS_NTFY_TOPIC", os.getenv("AGENTIC_NTFY_TOPIC", ""))
ROOT = os.getenv("DESK_ROOT_NOTIFY_EMAIL", "admin@ligbox.com.br")
def notify_finding(finding: dict) -> bool:
if finding.get("severity") not in ("high", "critical"):
return False
title = finding.get("title", "Agentic")
body = finding.get("suggested_human_action") or finding.get("detail_md", "")
if NTFY:
try:
req = urllib.request.Request(
f"https://ntfy.sh/{NTFY}", data=f"[Agentic] {title}\n{body}".encode(),
method="POST", headers={"Title": f"Agentic — {title}", "Priority": "high"},
)
urllib.request.urlopen(req, timeout=8)
except Exception:
pass
mail_notify.send_email(ROOT, f"[Ligbox Agentic] {title}", f"{body}\n— VM122")
return True