Archived
1
0
Fork 0

feat: anti-flapping

Send notifications only if the state duration is not instant. There are
a lot of replies with 0 seconds duration spamming channels.

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2021-07-07 15:36:03 +02:00
parent fbe5e5f723
commit 563d5ff9a6
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7

View file

@ -340,6 +340,7 @@ func handleProducts(parser Parser, notifiers []Notifier, filters []Filter, db *g
}
// send notifications
if duration > 0 {
if createThread {
for _, notifier := range notifiers {
if err := notifier.NotifyWhenAvailable(shop.Name, dbProduct.Name, dbProduct.Price, dbProduct.PriceCurrency, dbProduct.URL); err != nil {
@ -353,6 +354,7 @@ func handleProducts(parser Parser, notifiers []Notifier, filters []Filter, db *g
}
}
}
}
// keep track of active products
dbProduct.UpdatedAt = time.Now().Local()