From 8c5422af20289e67197a79c0c60efa7c9f000a40 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Thu, 19 May 2022 12:37:03 -0400 Subject: [PATCH] edge case for stuck notifications --- internal/worker/stuck_notifications.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/internal/worker/stuck_notifications.go b/internal/worker/stuck_notifications.go index 1ede379..cda9fde 100644 --- a/internal/worker/stuck_notifications.go +++ b/internal/worker/stuck_notifications.go @@ -175,13 +175,31 @@ func (snc *stuckNotificationsConsumer) Consume(delivery rmq.Delivery) { continue } - if !thing.IsDeleted() { + if thing.IsDeleted() { + break + } + + things, err := rac.MessageInbox(snc, reddit.WithQuery("after", account.LastMessageID)) + if err != nil { + snc.logger.WithFields(logrus.Fields{ + "err": err, + }).Error("failed to check inbox") + return + } + + if things.Count == 0 { snc.logger.WithFields(logrus.Fields{ "account#username": account.NormalizedUsername(), "thing#id": account.LastMessageID, - }).Debug("thing exists, returning") - return + }).Debug("thing exists, but not in inbox, marking as deleted") + break } + + snc.logger.WithFields(logrus.Fields{ + "account#username": account.NormalizedUsername(), + "thing#id": account.LastMessageID, + }).Debug("thing exists, returning") + return } }