summaryrefslogtreecommitdiff
path: root/DomainDig/LocalNotificationService.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-24 15:04:54 -0500
committerChristian Cleberg <[email protected]>2026-04-24 15:04:54 -0500
commit3f0b7746b1bee4c2f626eb805e3fd13c5f2f5d22 (patch)
tree17c710faf6191ac86ea5b6cab4df240cf2cefef9 /DomainDig/LocalNotificationService.swift
parentd0b3b7a15b59266b4ae4262fdb0364245092c17c (diff)
downloaddomain-dig-3f0b7746b1bee4c2f626eb805e3fd13c5f2f5d22.tar.gz
domain-dig-3f0b7746b1bee4c2f626eb805e3fd13c5f2f5d22.tar.bz2
domain-dig-3f0b7746b1bee4c2f626eb805e3fd13c5f2f5d22.zip
DomainDig v3.8.0 — Smart Monitoring
* Stable domain intervals * Frequent changes decrease intervals * Duplicate states do not trigger alerts * Quiet hours suppress alerts * Quiet hours across midnight work correctly * Sensitivity levels alter behavior as expected
Diffstat (limited to 'DomainDig/LocalNotificationService.swift')
-rw-r--r--DomainDig/LocalNotificationService.swift29
1 files changed, 29 insertions, 0 deletions
diff --git a/DomainDig/LocalNotificationService.swift b/DomainDig/LocalNotificationService.swift
index 7b43d67..93beca5 100644
--- a/DomainDig/LocalNotificationService.swift
+++ b/DomainDig/LocalNotificationService.swift
@@ -78,6 +78,35 @@ final class LocalNotificationService {
)
}
+ func notifyMonitoringSummary(
+ domain: String,
+ alerts: [MonitoringPendingAlert]
+ ) async {
+ let summary = alerts
+ .sorted { $0.detectedAt < $1.detectedAt }
+ .prefix(2)
+ .map(\.message)
+ .joined(separator: " • ")
+ let body: String
+ if alerts.count <= 1 {
+ body = alerts.first?.message ?? "Monitoring change detected"
+ } else if summary.isEmpty {
+ body = "\(alerts.count) monitoring changes detected"
+ } else {
+ body = "\(alerts.count) monitoring changes: \(summary)"
+ }
+
+ let severity = alerts.map(\.severity).max() ?? .info
+ let interruptionLevel: UNNotificationInterruptionLevel = severity == .critical ? .timeSensitive : .active
+
+ await schedule(
+ identifier: "monitoring-summary-\(domain)-\(UUID().uuidString)",
+ title: domain,
+ body: body,
+ interruptionLevel: interruptionLevel
+ )
+ }
+
func notifySweepComplete(summary: BatchSweepSummary) async {
let body = "\(summary.changedDomains) changed, \(summary.warningDomains) warnings, \(summary.unchangedDomains) unchanged"
await schedule(