From 2fc05e9bbbe2d26b238d3c231fda6d3429843411 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Thu, 20 Nov 2025 18:03:57 +0800 Subject: [PATCH] fix(monitor): check if LastSendNotification is zero (#23783) --- pkg/monitor/models/notification.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/monitor/models/notification.go b/pkg/monitor/models/notification.go index a9e7c88c43..66402e739c 100644 --- a/pkg/monitor/models/notification.go +++ b/pkg/monitor/models/notification.go @@ -241,7 +241,11 @@ func (n *SNotification) ShouldSendNotification() bool { if n.Frequency == 0 { return true } - if int64(time.Now().Sub(n.LastSendNotification)/time.Second)+int64(60) >= n.Frequency { + // 如果从未发送过通知(LastSendNotification 为零值),允许第一次发送 + if n.LastSendNotification.IsZero() { + return true + } + if int64(time.Since(n.LastSendNotification)/time.Second)+int64(60) >= n.Frequency { return true } return false