Skip to content

Commit

Permalink
Remove state change check for notify oneshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuckal777 committed Aug 1, 2023
1 parent 549196f commit 0758e70
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
8 changes: 2 additions & 6 deletions plugin/notification.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,13 @@ func (no *NotifyOneshot) ShouldNotify(params ShouldNotifyParams) bool {
log.Log.Info("NotifyOneshot: StateChange is zero")
return false
}
if params.Current.State == params.Last.State {
if log.LogDetails {
log.Log.Info("NotifyOneshot: no change in state")
}
return false
}
// already triggered for the current state
if params.Last.Time.After(params.StateChange) {
if log.LogDetails {
log.Log.Info("NotifyOneshot: already notified")
}
return false
}
// check that the current state is present for at least delay time
return time.Since(params.StateChange) >= no.Delay
}
18 changes: 0 additions & 18 deletions plugin/notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,24 +343,6 @@ var _ = Describe("NotifyOneshot", func() {
Expect(result).To(BeFalse())
})

It("does not trigger when the did not state change and the delay passes", func() {
schedule := NotifyOneshot{Delay: -5 * time.Minute}
now := time.Now()
result := schedule.ShouldNotify(ShouldNotifyParams{
Current: NotificationData{
State: "operational",
Time: now,
},
Last: NotificationData{
State: "operational",
Time: now,
},
Log: SchedLog,
StateChange: now,
})
Expect(result).To(BeFalse())
})

It("does not trigger when StateChange is zero", func() {
schedule := NotifyOneshot{Delay: -5 * time.Minute}
now := time.Now()
Expand Down

0 comments on commit 0758e70

Please sign in to comment.