From 2472613d90bd8704b75ab0357a2479b45369b0b0 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Wed, 16 Oct 2024 03:25:21 +0200 Subject: [PATCH] Ignore old notifications --- main.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main.go b/main.go index 16006d5..254869f 100644 --- a/main.go +++ b/main.go @@ -44,6 +44,13 @@ func tickGameStart(c *sn.Client) { for _, n := range mentions { + // we only care about current notifications + x := time.Now().Add(-30 * time.Second) + if n.Item.CreatedAt.Before(x) { + log.Println("ignoring old mention %d", n.Item.Id) + continue + } + if exists, err := db.ItemHasReply(n.Item.Id, meId); err != nil { log.Printf("failed to check for existing reply to game start in item %d: %v\n", n.Item.Id, err) continue @@ -88,6 +95,13 @@ func tickGameProgress(c *sn.Client) { for _, n := range replies { + // we only care about current notifications + x := time.Now().Add(-30 * time.Second) + if n.Item.CreatedAt.Before(x) { + log.Println("ignoring old reply %d", n.Item.Id) + continue + } + if exists, err := db.ItemHasReply(n.Item.Id, meId); err != nil { log.Printf("failed to check for existing reply to game update in item %d: %v\n", n.Item.Id, err) continue