Skip to content

Commit

Permalink
handle oauth revoked errors in watchers
Browse files Browse the repository at this point in the history
  • Loading branch information
andremedeiros committed Nov 9, 2022
1 parent e23d47f commit 0ca21ff
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion internal/worker/subreddits.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,17 @@ func (sc *subredditsConsumer) Consume(delivery rmq.Delivery) {
zap.String("subreddit#name", subreddit.NormalizedName()),
zap.Int("page", page),
)
continue

if err == reddit.ErrOauthRevoked {
sc.logger.Info("deleting watcher",
zap.Int64("subreddit#id", id),
zap.String("subreddit#name", subreddit.NormalizedName()),
zap.Int64("watcher#id", watcher.ID),
)
_ = sc.watcherRepo.Delete(ctx, watcher.ID)
}

return
}

sc.logger.Debug("loaded new posts",
Expand Down Expand Up @@ -283,6 +293,15 @@ func (sc *subredditsConsumer) Consume(delivery rmq.Delivery) {
zap.Int64("subreddit#id", id),
zap.String("subreddit#name", subreddit.NormalizedName()),
)

if err == reddit.ErrOauthRevoked {
sc.logger.Info("deleting watcher",
zap.Int64("subreddit#id", id),
zap.String("subreddit#name", subreddit.NormalizedName()),
zap.Int64("watcher#id", watcher.ID),
)
_ = sc.watcherRepo.Delete(ctx, watcher.ID)
}
} else {
sc.logger.Debug("loaded hot posts",
zap.Int64("subreddit#id", id),
Expand Down

0 comments on commit 0ca21ff

Please sign in to comment.