Skip to content

Commit ce8f84a

Browse files
authored
fix(monitor): check if LastSendNotification is zero (#23782)
1 parent c54bca0 commit ce8f84a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/monitor/models/notification.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,11 @@ func (n *SNotification) ShouldSendNotification() bool {
237237
if n.Frequency == 0 {
238238
return true
239239
}
240-
if int64(time.Now().Sub(n.LastSendNotification)/time.Second)+int64(60) >= n.Frequency {
240+
// 如果从未发送过通知(LastSendNotification 为零值),允许第一次发送
241+
if n.LastSendNotification.IsZero() {
242+
return true
243+
}
244+
if int64(time.Since(n.LastSendNotification)/time.Second)+int64(60) >= n.Frequency {
241245
return true
242246
}
243247
return false

0 commit comments

Comments
 (0)