feat: notify RD Gateway events in Telegram outside min_severity

Route rdg.connection.* through notify_rdg_connection and add disconnected type.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-01 08:14:37 +10:00
parent 7e13be3c38
commit bc77f82307
5 changed files with 52 additions and 2 deletions
+13
View File
@@ -15,6 +15,11 @@ logger = logging.getLogger(__name__)
LIFECYCLE_EVENT_TYPE = "agent.lifecycle"
DAILY_REPORT_EVENT_TYPES = frozenset({"report.daily.ssh", "report.daily.rdp"})
AUTH_LOGIN_SUCCESS_TYPES = frozenset({"rdp.login.success", "ssh.login.success"})
RDG_CONNECTION_TYPES = frozenset({
"rdg.connection.success",
"rdg.connection.disconnected",
"rdg.connection.failed",
})
def _event_telegram_via_agent(event: Event) -> bool:
@@ -94,3 +99,11 @@ def notify_auth_login(event: Event, *, db: Session | None = None) -> None:
if not should_notify_event(event, db):
return
_dispatch_lifecycle_channels(event, db=db, policy=policy)
def notify_rdg_connection(event: Event, *, db: Session | None = None) -> None:
"""RD Gateway 302/303 — ingest всегда; Telegram SAC вне min_severity (как auth login)."""
policy = get_effective_notification_policy(db)
if not should_notify_event(event, db):
return
_dispatch_lifecycle_channels(event, db=db, policy=policy)
+6 -2
View File
@@ -428,8 +428,12 @@ def format_event_telegram_html(event: Event) -> str:
def _format_rdg_html(event: Event) -> str:
details = _details_dict(event)
ok = event.type.endswith(".success")
header = "✅ RD Gateway: подключение" if ok else "❌ RD Gateway: ошибка"
if event.type.endswith(".success"):
header = "✅ RD Gateway: подключение"
elif event.type.endswith(".disconnected"):
header = "️ RD Gateway: отключение"
else:
header = "❌ RD Gateway: ошибка"
msg = f"<b>{header}</b>\n"
msg += _line("👤", "Пользователь", html_escape(_detail(details, "user", "username")))
msg += _line("🏢", "Хост", host_label(event.host))