From dfae5d6c770e6f596e58c0d096f634e62f377e88 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Fri, 14 Jan 2022 15:29:56 -0500 Subject: [PATCH] check if notification was sent too --- internal/worker/notifications.go | 2 +- internal/worker/subreddits.go | 2 +- internal/worker/trending.go | 2 +- internal/worker/users.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/worker/notifications.go b/internal/worker/notifications.go index d5e7c3b..94df6f3 100644 --- a/internal/worker/notifications.go +++ b/internal/worker/notifications.go @@ -333,7 +333,7 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) { } res, err := client.Push(notification) - if err != nil { + if err != nil || !res.Sent() { _ = nc.statsd.Incr("apns.notification.errors", []string{}, 1) nc.logger.WithFields(logrus.Fields{ "account#username": account.NormalizedUsername(), diff --git a/internal/worker/subreddits.go b/internal/worker/subreddits.go index 2f14ab8..6bd14f8 100644 --- a/internal/worker/subreddits.go +++ b/internal/worker/subreddits.go @@ -401,7 +401,7 @@ func (sc *subredditsConsumer) Consume(delivery rmq.Delivery) { } res, err := client.Push(notification) - if err != nil { + if err != nil || !res.Sent() { _ = sc.statsd.Incr("apns.notification.errors", []string{}, 1) sc.logger.WithFields(logrus.Fields{ "subreddit#id": subreddit.ID, diff --git a/internal/worker/trending.go b/internal/worker/trending.go index 6712338..db86181 100644 --- a/internal/worker/trending.go +++ b/internal/worker/trending.go @@ -286,7 +286,7 @@ func (tc *trendingConsumer) Consume(delivery rmq.Delivery) { } res, err := client.Push(notification) - if err != nil { + if err != nil || !res.Sent() { _ = tc.statsd.Incr("apns.notification.errors", []string{}, 1) tc.logger.WithFields(logrus.Fields{ "subreddit#id": subreddit.ID, diff --git a/internal/worker/users.go b/internal/worker/users.go index b4abb39..ecb8ae8 100644 --- a/internal/worker/users.go +++ b/internal/worker/users.go @@ -281,7 +281,7 @@ func (uc *usersConsumer) Consume(delivery rmq.Delivery) { } res, err := client.Push(notification) - if err != nil { + if err != nil || !res.Sent() { _ = uc.statsd.Incr("apns.notification.errors", []string{}, 1) uc.logger.WithFields(logrus.Fields{ "user#id": user.ID,