Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Lite/Services/EmailTemplateBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal static class EmailTemplateBuilder
{
private const string EditionName = "Performance Monitor Lite";
private const string FontStack = "-apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif";
private const string SnoozeHint = "To silence this alert: open Performance Monitor Lite → Settings → Manage Mute Rules";

/// <summary>
/// Builds both HTML and plain-text bodies for an alert email.
Expand Down Expand Up @@ -174,6 +175,10 @@ private static string BuildHtmlBody(
sb.Append($" &middot; {emailCooldownMinutes}-minute cooldown between repeat alerts");
}
sb.Append("</span>");
if (!isTest)
{
sb.Append($"<br><span style=\"font-family:{FontStack};font-size:11px;color:#B0B0B0;\">{WebUtility.HtmlEncode(SnoozeHint)}</span>");
}
sb.Append("</td></tr>");

/* Close inner table */
Expand Down Expand Up @@ -282,6 +287,8 @@ private static string BuildPlainTextBody(
sb.Append($"\r\nAttached: {context.AttachmentFileName}\r\n");
}

sb.Append($"\r\n{SnoozeHint}\r\n");

return sb.ToString();
}
}
20 changes: 16 additions & 4 deletions Lite/Services/WebhookAlertService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace PerformanceMonitorLite.Services;
public class WebhookAlertService
{
private const string EditionName = "Performance Monitor Lite";
private const string SnoozeHint = "To silence this alert: open Performance Monitor Lite → Settings → Manage Mute Rules";
private static readonly JsonSerializerOptions s_jsonOptions = new() { PropertyNamingPolicy = null };

private readonly ConcurrentDictionary<string, DateTime> _cooldowns = new();
Expand Down Expand Up @@ -221,6 +222,11 @@ internal static string BuildTeamsPayload(
}
};

if (!isTest)
{
sections.Add(new { text = SnoozeHint });
}

var card = new
{
@type = "MessageCard",
Expand Down Expand Up @@ -346,13 +352,19 @@ internal static string BuildSlackPayload(
}
}

var contextElements = new List<object>
{
new { type = "mrkdwn", text = $"Sent by {EditionName}" }
};
if (!isTest)
{
contextElements.Add(new { type = "mrkdwn", text = SnoozeHint });
}

blocks.Add(new
{
type = "context",
elements = new object[]
{
new { type = "mrkdwn", text = $"Sent by {EditionName}" }
}
elements = contextElements
});

var payload = new
Expand Down
Loading