fix: dedupe daily report Telegram in dual mode and show host in summary fallback
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -75,11 +75,14 @@ def _dispatch_lifecycle_channels(event: Event, *, db: Session | None, policy) ->
|
||||
|
||||
|
||||
def notify_daily_report(event: Event, *, db: Session | None = None) -> None:
|
||||
"""Оповещение по суточному отчёту (severity=info, вне порога policy)."""
|
||||
"""Оповещение по суточному отчёту (severity=info, вне порога policy).
|
||||
|
||||
При UseSAC=dual агент шлёт TG сам (telegram_via=agent) — SAC не дублирует.
|
||||
"""
|
||||
policy = get_effective_notification_policy(db)
|
||||
if not should_notify_event(event, db):
|
||||
return
|
||||
_dispatch_event_channels(event, db=db, policy=policy)
|
||||
_dispatch_lifecycle_channels(event, db=db, policy=policy)
|
||||
|
||||
|
||||
def notify_lifecycle(event: Event, *, db: Session | None = None) -> None:
|
||||
|
||||
@@ -405,7 +405,15 @@ def _format_event_body_html(event: Event) -> str:
|
||||
return re.sub(r"\n{3,}", "\n\n", text)
|
||||
body = _detail(details, "report_body", default=event.summary)
|
||||
if body != "-":
|
||||
return html.escape(body)
|
||||
header = (
|
||||
"📊 ЕЖЕДНЕВНЫЙ ОТЧЕТ МОНИТОРИНГА WINDOWS"
|
||||
if event.type == "report.daily.rdp"
|
||||
else "📊 ЕЖЕДНЕВНЫЙ ОТЧЕТ SSH МОНИТОРИНГА"
|
||||
)
|
||||
msg = f"<b>{html.escape(header)}</b>\n"
|
||||
msg += _line("🏢", "Сервер", host_label(event.host))
|
||||
msg += f"\n{html.escape(body)}"
|
||||
return msg
|
||||
return format_generic_event_html(event)
|
||||
if event.type in ("rdp.login.success", "rdp.login.failed"):
|
||||
return format_rdp_login_html(event)
|
||||
|
||||
Reference in New Issue
Block a user