mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-12 23:17:44 +00:00
things
This commit is contained in:
parent
0ca21ffcb4
commit
d6b967188c
3 changed files with 12 additions and 3 deletions
|
@ -5,7 +5,6 @@ linters:
|
|||
- errname # checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`
|
||||
- exportloopref # checks for pointers to enclosing loop variables
|
||||
- gochecknoinits # checks that no init functions are present in Go code
|
||||
- ifshort # checks that your code uses short syntax for if-statements whenever possible
|
||||
- importas # enforces consistent import aliases
|
||||
- ineffassign # detects when assignments to existing variables are not used
|
||||
- noctx # finds sending http request without context.Context
|
||||
|
|
|
@ -56,6 +56,7 @@ var (
|
|||
defaultErrorMap = map[int]error{
|
||||
401: ErrOauthRevoked,
|
||||
403: ErrOauthRevoked,
|
||||
404: ErrSubredditNotFound,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -219,13 +219,22 @@ func (sc *subredditsConsumer) Consume(delivery rmq.Delivery) {
|
|||
zap.Int("page", page),
|
||||
)
|
||||
|
||||
if err == reddit.ErrOauthRevoked {
|
||||
switch err {
|
||||
case 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)
|
||||
case reddit.ErrSubredditNotFound:
|
||||
sc.logger.Info("subreddit deleted, deleting watchers",
|
||||
zap.Int64("subreddit#id", id),
|
||||
zap.String("subreddit#name", subreddit.NormalizedName()),
|
||||
)
|
||||
for _, watcher := range watchers {
|
||||
_ = sc.watcherRepo.Delete(ctx, watcher.ID)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -447,7 +456,7 @@ func (sc *subredditsConsumer) Consume(delivery rmq.Delivery) {
|
|||
)
|
||||
} else if !res.Sent() {
|
||||
_ = sc.statsd.Incr("apns.notification.errors", []string{}, 1)
|
||||
sc.logger.Error("notificaion not sent",
|
||||
sc.logger.Error("notification not sent",
|
||||
zap.Int64("subreddit#id", id),
|
||||
zap.String("subreddit#name", subreddit.NormalizedName()),
|
||||
zap.String("post#id", post.ID),
|
||||
|
|
Loading…
Reference in a new issue