From 4f200fd26a9301dab0c3d9321da77dca3384b9ba Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Sat, 5 Nov 2022 16:15:04 -0400 Subject: [PATCH] spam prevention --- internal/worker/notifications.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/worker/notifications.go b/internal/worker/notifications.go index a2e714e..27ed694 100644 --- a/internal/worker/notifications.go +++ b/internal/worker/notifications.go @@ -263,6 +263,15 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) { } } + // Let's populate this with the latest message so we don't flood users with stuff + if account.CheckCount == 0 { + logger.Debug("populating first message id to prevent spamming") + + account.CheckCount = 1 + _ = nc.accountRepo.Update(ctx, &account) + return + } + devices, err := nc.deviceRepo.GetInboxNotifiableByAccountID(ctx, account.ID) if err != nil { logger.Error("failed to fetch account devices", zap.Error(err))