only alert on non deleted messages

This commit is contained in:
Andre Medeiros 2021-10-17 11:05:40 -04:00
parent 78e48a8f3b
commit b07bf599de

View file

@ -280,7 +280,14 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) {
"count": msgs.Count, "count": msgs.Count,
}).Debug("fetched messages") }).Debug("fetched messages")
account.LastMessageID = msgs.Children[0].FullName() for i := msgs.Count - 1; i >= 0; i-- {
msg := msgs.Children[i]
if !msg.IsDeleted() {
account.LastMessageID = msgs.Children[0].FullName()
break
}
}
if err = nc.accountRepo.Update(ctx, &account); err != nil { if err = nc.accountRepo.Update(ctx, &account); err != nil {
nc.logger.WithFields(logrus.Fields{ nc.logger.WithFields(logrus.Fields{
@ -310,6 +317,11 @@ func (nc *notificationsConsumer) Consume(delivery rmq.Delivery) {
// Iterate backwards so we notify from older to newer // Iterate backwards so we notify from older to newer
for i := msgs.Count - 1; i >= 0; i-- { for i := msgs.Count - 1; i >= 0; i-- {
msg := msgs.Children[i] msg := msgs.Children[i]
if msg.IsDeleted() {
continue
}
notification := &apns2.Notification{} notification := &apns2.Notification{}
notification.Topic = "com.christianselig.Apollo" notification.Topic = "com.christianselig.Apollo"
notification.Payload = payloadFromMessage(account, msg, msgs.Count) notification.Payload = payloadFromMessage(account, msg, msgs.Count)