mirror of
https://github.com/christianselig/apollo-backend
synced 2024-11-25 21:27:42 +00:00
handle edge case of ending without comment
This commit is contained in:
parent
1a5f919bb9
commit
0bee289aa6
1 changed files with 14 additions and 8 deletions
|
@ -248,7 +248,7 @@ func (lac *liveActivitiesConsumer) Consume(delivery rmq.Delivery) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(candidates) == 0 {
|
if len(candidates) == 0 && la.ExpiresAt.After(now) {
|
||||||
lac.logger.Debug("no new comments found", zap.String("live_activity#apns_token", at))
|
lac.logger.Debug("no new comments found", zap.String("live_activity#apns_token", at))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -257,16 +257,19 @@ func (lac *liveActivitiesConsumer) Consume(delivery rmq.Delivery) {
|
||||||
return candidates[i].Score > candidates[j].Score
|
return candidates[i].Score > candidates[j].Score
|
||||||
})
|
})
|
||||||
|
|
||||||
comment := candidates[0]
|
|
||||||
|
|
||||||
din := DynamicIslandNotification{
|
din := DynamicIslandNotification{
|
||||||
PostCommentCount: tr.Post.NumComments,
|
PostCommentCount: tr.Post.NumComments,
|
||||||
PostScore: tr.Post.Score,
|
PostScore: tr.Post.Score,
|
||||||
CommentID: comment.ID,
|
}
|
||||||
CommentAuthor: comment.Author,
|
|
||||||
CommentBody: comment.Body,
|
if len(candidates) > 1 {
|
||||||
CommentAge: comment.CreatedAt.Unix(),
|
comment := candidates[0]
|
||||||
CommentScore: comment.Score,
|
|
||||||
|
din.CommentID = comment.ID
|
||||||
|
din.CommentAuthor = comment.Author
|
||||||
|
din.CommentBody = comment.Body
|
||||||
|
din.CommentAge = comment.CreatedAt.Unix()
|
||||||
|
din.CommentScore = comment.Score
|
||||||
}
|
}
|
||||||
|
|
||||||
ev := "update"
|
ev := "update"
|
||||||
|
@ -301,6 +304,7 @@ func (lac *liveActivitiesConsumer) Consume(delivery rmq.Delivery) {
|
||||||
lac.logger.Error("failed to send notification",
|
lac.logger.Error("failed to send notification",
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
zap.String("live_activity#apns_token", at),
|
zap.String("live_activity#apns_token", at),
|
||||||
|
zap.String("notification#type", ev),
|
||||||
)
|
)
|
||||||
|
|
||||||
_ = lac.liveActivityRepo.Delete(ctx, at)
|
_ = lac.liveActivityRepo.Delete(ctx, at)
|
||||||
|
@ -308,6 +312,7 @@ func (lac *liveActivitiesConsumer) Consume(delivery rmq.Delivery) {
|
||||||
_ = lac.statsd.Incr("apns.live_activities.errors", []string{}, 1)
|
_ = lac.statsd.Incr("apns.live_activities.errors", []string{}, 1)
|
||||||
lac.logger.Error("notification not sent",
|
lac.logger.Error("notification not sent",
|
||||||
zap.String("live_activity#apns_token", at),
|
zap.String("live_activity#apns_token", at),
|
||||||
|
zap.String("notification#type", ev),
|
||||||
zap.Int("response#status", res.StatusCode),
|
zap.Int("response#status", res.StatusCode),
|
||||||
zap.String("response#reason", res.Reason),
|
zap.String("response#reason", res.Reason),
|
||||||
)
|
)
|
||||||
|
@ -317,6 +322,7 @@ func (lac *liveActivitiesConsumer) Consume(delivery rmq.Delivery) {
|
||||||
_ = lac.statsd.Incr("apns.notification.sent", []string{}, 1)
|
_ = lac.statsd.Incr("apns.notification.sent", []string{}, 1)
|
||||||
lac.logger.Debug("sent notification",
|
lac.logger.Debug("sent notification",
|
||||||
zap.String("live_activity#apns_token", at),
|
zap.String("live_activity#apns_token", at),
|
||||||
|
zap.String("notification#type", ev),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue