mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-25 05:07:43 +00:00
actually remember last message id so we don't duplicate notifications
This commit is contained in:
parent
3ce858927b
commit
b9373832eb
1 changed files with 19 additions and 21 deletions
|
@ -327,9 +327,6 @@ func (c *Consumer) Consume(delivery rmq.Delivery) {
|
||||||
|
|
||||||
// Set latest message we alerted on
|
// Set latest message we alerted on
|
||||||
latestMsg := msgs.MessageListing.Messages[0]
|
latestMsg := msgs.MessageListing.Messages[0]
|
||||||
|
|
||||||
// Let's populate this with the latest message so we don't flood users with stuff
|
|
||||||
if account.LastMessageID == "" {
|
|
||||||
if err = c.pool.BeginFunc(ctx, func(tx pgx.Tx) error {
|
if err = c.pool.BeginFunc(ctx, func(tx pgx.Tx) error {
|
||||||
stmt := `
|
stmt := `
|
||||||
UPDATE accounts
|
UPDATE accounts
|
||||||
|
@ -342,15 +339,16 @@ func (c *Consumer) Consume(delivery rmq.Delivery) {
|
||||||
"accountID": id,
|
"accountID": id,
|
||||||
"err": err,
|
"err": err,
|
||||||
}).Error("failed to update last_message_id for account")
|
}).Error("failed to update last_message_id for account")
|
||||||
|
|
||||||
delivery.Reject()
|
delivery.Reject()
|
||||||
} else {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Let's populate this with the latest message so we don't flood users with stuff
|
||||||
|
if account.LastMessageID == "" {
|
||||||
c.logger.WithFields(logrus.Fields{
|
c.logger.WithFields(logrus.Fields{
|
||||||
"accountID": delivery.Payload(),
|
"accountID": delivery.Payload(),
|
||||||
}).Debug("populating first message ID to prevent spamming")
|
}).Debug("populating first message ID to prevent spamming")
|
||||||
|
|
||||||
delivery.Ack()
|
delivery.Ack()
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue