From 0b7eca3f77a9ec03dba1da7eade9a7a296a7260c Mon Sep 17 00:00:00 2001 From: Till Faelligen <2353100+S7evinK@users.noreply.github.com> Date: Mon, 26 Sep 2022 09:54:06 +0200 Subject: [PATCH] Tweaks --- userapi/consumers/clientapi.go | 8 ++++---- userapi/internal/api.go | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/userapi/consumers/clientapi.go b/userapi/consumers/clientapi.go index 62098fb37..17d19f5f3 100644 --- a/userapi/consumers/clientapi.go +++ b/userapi/consumers/clientapi.go @@ -105,14 +105,14 @@ func (s *OutputReceiptEventConsumer) onMessage(ctx context.Context, msgs []*nats return false } - if !updated { - return true - } - if err = s.syncProducer.GetAndSendNotificationData(ctx, userID, roomID); err != nil { log.WithError(err).Error("userapi EDU consumer: GetAndSendNotificationData failed") return false } + + if !updated { + return true + } if err = util.NotifyUserCountsAsync(ctx, s.pgClient, localpart, s.db); err != nil { log.WithError(err).Error("userapi EDU consumer: NotifyUserCounts failed") return false diff --git a/userapi/internal/api.go b/userapi/internal/api.go index 98f24ff6e..a9a8c30ac 100644 --- a/userapi/internal/api.go +++ b/userapi/internal/api.go @@ -112,15 +112,17 @@ func (a *UserInternalAPI) setFullyRead(ctx context.Context, req *api.InputAccoun logrus.WithError(err).Errorf("UserInternalAPI.setFullyRead: DeleteNotificationsUpTo failed") return err } - // nothing changed, no need to send notification data/notify push gateway - if !deleted { - return nil - } if err = a.SyncProducer.GetAndSendNotificationData(ctx, req.UserID, req.RoomID); err != nil { logrus.WithError(err).Error("UserInternalAPI.setFullyRead: GetAndSendNotificationData failed") return err } + + // nothing changed, no need to notify the push gateway + if !deleted { + return nil + } + if err = userapiUtil.NotifyUserCountsAsync(ctx, a.PgClient, localpart, a.DB); err != nil { logrus.WithError(err).Error("UserInternalAPI.setFullyRead: NotifyUserCounts failed") return err