mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-05-20 04:43:46 +02:00
Add logs to debug read receipts
This commit is contained in:
parent
fea25f92ec
commit
c4a7943775
|
@ -51,6 +51,7 @@ func (user *User) SetLastReadTS(portal PortalKey, ts time.Time) {
|
|||
if err != nil {
|
||||
user.log.Warnfln("Failed to update last read timestamp: %v", err)
|
||||
} else {
|
||||
user.log.Debugfln("Set last read timestamp of %s in %s to %d", user.MXID, portal.String(), ts.Unix())
|
||||
user.lastReadCache[portal] = ts
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2421,8 +2421,10 @@ func (portal *Portal) HandleMatrixReadReceipt(sender *User, eventID id.EventID,
|
|||
}
|
||||
|
||||
prevTimestamp := sender.GetLastReadTS(portal.Key)
|
||||
lastReadIsZero := false
|
||||
if prevTimestamp.IsZero() {
|
||||
prevTimestamp = maxTimestamp.Add(-2 * time.Second)
|
||||
lastReadIsZero = true
|
||||
}
|
||||
|
||||
messages := portal.bridge.DB.Message.GetMessagesBetween(portal.Key, prevTimestamp, maxTimestamp)
|
||||
|
@ -2442,7 +2444,8 @@ func (portal *Portal) HandleMatrixReadReceipt(sender *User, eventID id.EventID,
|
|||
} // else: blank key (participant field isn't needed in direct chat read receipts)
|
||||
groupedMessages[key] = append(groupedMessages[key], msg.JID)
|
||||
}
|
||||
portal.log.Debugfln("Sending read receipts by %s: %v", sender.JID, groupedMessages)
|
||||
portal.log.Debugfln("Sending read receipts by %s (last read: %d, was zero: %t): %v",
|
||||
sender.JID, prevTimestamp.Unix(), lastReadIsZero, groupedMessages)
|
||||
for messageSender, ids := range groupedMessages {
|
||||
chatJID := portal.Key.JID
|
||||
if messageSender.Server == types.BroadcastServer {
|
||||
|
|
2
user.go
2
user.go
|
@ -897,6 +897,8 @@ func (user *User) markSelfReadFull(portal *Portal) {
|
|||
err := puppet.CustomIntent().MarkReadWithContent(portal.MXID, lastMessage.MXID, &CustomReadReceipt{DoublePuppetSource: doublePuppetValue})
|
||||
if err != nil {
|
||||
user.log.Warnfln("Failed to mark %s (last message) in %s as read: %v", lastMessage.MXID, portal.MXID, err)
|
||||
} else {
|
||||
user.log.Debugfln("Marked %s (last message) in %s as read", lastMessage.MXID, portal.MXID)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue