spam prevention

This commit is contained in:
Andre Medeiros 2022-11-05 16:15:04 -04:00
parent af538e6f42
commit 4f200fd26a

View file

@ -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) devices, err := nc.deviceRepo.GetInboxNotifiableByAccountID(ctx, account.ID)
if err != nil { if err != nil {
logger.Error("failed to fetch account devices", zap.Error(err)) logger.Error("failed to fetch account devices", zap.Error(err))