Pull latest hnt/dendrite into Harmony (#449)

Merge commit '46f0ed379a23768853df9c917e1eaf16899ceda3' into
austin.ellis/dendrite

Signed-off-by: Brian Meek <brian@hntlabs.com>
Signed-off-by: Austin Ellis <austin@hntlabs.com>
Co-authored-by: Brian Meek <brian@hntlabs.com>
This commit is contained in:
texuf 2022-09-15 10:42:13 -07:00 committed by GitHub
parent ad658f8aa4
commit fd4673ccb9

View file

@ -95,22 +95,27 @@ func (s *OutputReadUpdateConsumer) onMessage(ctx context.Context, msgs []*nats.M
log.Tracef("Received read update from sync API: %#v", read) log.Tracef("Received read update from sync API: %#v", read)
if read.Read > 0 { if read.Read > 0 {
updated, err := s.db.SetNotificationsRead(ctx, localpart, roomID, int64(read.Read), true) /*updated*/ _, err := s.db.SetNotificationsRead(ctx, localpart, roomID, int64(read.Read), true)
if err != nil { if err != nil {
log.WithError(err).Error("userapi EDU consumer") log.WithError(err).Error("userapi EDU consumer")
return false return false
} }
if updated { // zion hack - always send the notification data
if err = s.syncProducer.GetAndSendNotificationData(ctx, userID, roomID); err != nil { // the notifications are stored in two different databases, and somehow the notification database
log.WithError(err).Error("userapi EDU consumer: GetAndSendNotificationData failed") // prunes data, so trying to mark old notifications as read will fail, but the notification will still exist in the other db
return false // todo, revist when this refactor lands: https://github.com/matrix-org/dendrite/pull/2688/files
}
if err = util.NotifyUserCountsAsync(ctx, s.pgClient, localpart, s.db); err != nil { //if updated {
log.WithError(err).Error("userapi EDU consumer: NotifyUserCounts failed") if err = s.syncProducer.GetAndSendNotificationData(ctx, userID, roomID); err != nil {
return false log.WithError(err).Error("userapi EDU consumer: GetAndSendNotificationData failed")
} return false
} }
if err = util.NotifyUserCountsAsync(ctx, s.pgClient, localpart, s.db); err != nil {
log.WithError(err).Error("userapi EDU consumer: NotifyUserCounts failed")
return false
}
//}
} }
if read.FullyRead > 0 { if read.FullyRead > 0 {