From ce8f84add6c7b13d8a80c8bbb9c1e6958d3bace3 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Thu, 20 Nov 2025 18:04:10 +0800 Subject: [PATCH] fix(monitor): check if LastSendNotification is zero (#23782) --- 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 e4ed6466be..019f822bfb 100644 --- a/pkg/monitor/models/notification.go +++ b/pkg/monitor/models/notification.go @@ -237,7 +237,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