diff --git a/internal/reddit/types.go b/internal/reddit/types.go index 1c5614a..4a170ee 100644 --- a/internal/reddit/types.go +++ b/internal/reddit/types.go @@ -85,6 +85,10 @@ func (t *Thing) FullName() string { return fmt.Sprintf("%s_%s", t.Kind, t.ID) } +func (t *Thing) IsDeleted() bool { + return t.Author == "[deleted]" +} + func NewThing(val *fastjson.Value) *Thing { t := &Thing{} diff --git a/internal/worker/stuck_notifications.go b/internal/worker/stuck_notifications.go index d53fe8f..f57ae78 100644 --- a/internal/worker/stuck_notifications.go +++ b/internal/worker/stuck_notifications.go @@ -173,7 +173,7 @@ func (snc *stuckNotificationsConsumer) Consume(delivery rmq.Delivery) { continue } - if thing.Author != "[deleted]" { + if !thing.IsDeleted() { snc.logger.WithFields(logrus.Fields{ "account#username": account.NormalizedUsername(), "thing#id": account.LastMessageID, @@ -203,9 +203,10 @@ func (snc *stuckNotificationsConsumer) Consume(delivery rmq.Delivery) { account.LastMessageID = "" for _, thing := range things.Children { - if lastAlertedAt > thing.CreatedAt { + if lastAlertedAt > thing.CreatedAt && !thing.IsDeleted() { break } + account.LastMessageID = thing.FullName() }