Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset notifyAfterCount on Success #67

Merged
merged 3 commits into from
Nov 26, 2021
Merged
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
11 changes: 5 additions & 6 deletions types/services/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ func sendSuccess(s *Service) {
return
}

s.notifyAfterCount = 0

if s.prevOnline == s.Online {
return
}
s.prevOnline = true

for _, n := range allNotifiers {
notif := n.Select()
Expand All @@ -42,9 +45,6 @@ func sendSuccess(s *Service) {
notif.LastSent = utils.Now()
}
}

s.prevOnline = true
s.notifyAfterCount++
}

func sendFailure(s *Service, f *failures.Failure) {
Expand All @@ -63,6 +63,8 @@ func sendFailure(s *Service, f *failures.Failure) {
}
}

s.prevOnline = false

for _, n := range allNotifiers {
notif := n.Select()
if notif.CanSend() {
Expand All @@ -78,9 +80,6 @@ func sendFailure(s *Service, f *failures.Failure) {
notif.LastSent = utils.Now()
}
}

s.prevOnline = false
s.notifyAfterCount++
}

func logMessage(method string, msg string, error error, onSuccesss bool, serviceId int64) {
Expand Down