check for last alerted thing that wasn't deleted

This commit is contained in:
Andre Medeiros 2021-10-17 11:02:31 -04:00
parent ad982edcd7
commit 78e48a8f3b
2 changed files with 7 additions and 2 deletions

View file

@ -85,6 +85,10 @@ func (t *Thing) FullName() string {
return fmt.Sprintf("%s_%s", t.Kind, t.ID)
}
func (t *Thing) IsDeleted() bool {
return t.Author == "[deleted]"
}
func NewThing(val *fastjson.Value) *Thing {
t := &Thing{}

View file

@ -173,7 +173,7 @@ func (snc *stuckNotificationsConsumer) Consume(delivery rmq.Delivery) {
continue
}
if thing.Author != "[deleted]" {
if !thing.IsDeleted() {
snc.logger.WithFields(logrus.Fields{
"account#username": account.NormalizedUsername(),
"thing#id": account.LastMessageID,
@ -203,9 +203,10 @@ func (snc *stuckNotificationsConsumer) Consume(delivery rmq.Delivery) {
account.LastMessageID = ""
for _, thing := range things.Children {
if lastAlertedAt > thing.CreatedAt {
if lastAlertedAt > thing.CreatedAt && !thing.IsDeleted() {
break
}
account.LastMessageID = thing.FullName()
}