Some checks are pending
CI / Integration (mcr.microsoft.com/mssql/server:2019-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2022-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2025-latest) (push) Blocked by required conditions
CI / Build og unit tests (push) Waiting to run
CI / Integration (mcr.microsoft.com/mssql/server:2017-latest) (push) Blocked by required conditions
- Repository reports which findings opened and resolved per evaluation - Agent notifies on new and resolved findings and on instance unreachable/recovered transitions, with links to the web UI - Channels: e-mail (MailKit, HTML-encoded), Microsoft Teams Workflows webhook (Adaptive Card), generic JSON webhook signed with HMAC-SHA256 - Per-channel minimum severity (outages always sent), one message per batch, hourly cap per channel; a failing channel never stops monitoring - Tested with a real SMTP server (Mailpit) and the real agent pipeline Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E3EExwndy8Z22EK2Qpt6BK
34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using SQLInsight.Core.Findings;
|
|
|
|
namespace SQLInsight.Notifications;
|
|
|
|
internal static class Texts
|
|
{
|
|
public static string Severity(Severity severity) => severity switch
|
|
{
|
|
Core.Findings.Severity.Critical => "Kritisk",
|
|
Core.Findings.Severity.High => "Høj",
|
|
Core.Findings.Severity.Medium => "Middel",
|
|
Core.Findings.Severity.Low => "Lav",
|
|
_ => "Info",
|
|
};
|
|
|
|
public static string Headline(Notification n) => n.Kind switch
|
|
{
|
|
NotificationKind.FindingOpened => $"[{Severity(n.Severity)}] {n.Instance}: {n.Title}",
|
|
NotificationKind.FindingResolved => $"[Løst] {n.Instance}: {n.Title}",
|
|
NotificationKind.InstanceUnreachable => $"[Kan ikke nås] {n.Instance}",
|
|
NotificationKind.InstanceRecovered => $"[Svarer igen] {n.Instance}",
|
|
_ => n.Title,
|
|
};
|
|
|
|
public static string Subject(IReadOnlyList<Notification> batch) => batch.Count == 1
|
|
? "SQLInsight: " + Headline(batch[0])
|
|
: $"SQLInsight: {batch.Count} hændelser på {string.Join(", ", batch.Select(n => n.Instance).Distinct())}";
|
|
|
|
public static string FirstSentence(string text)
|
|
{
|
|
var end = text.IndexOf(". ", StringComparison.Ordinal);
|
|
return end < 0 ? text : text[..(end + 1)];
|
|
}
|
|
}
|