forked from MirrorHub/mautrix-whatsapp
Fix double puppet marker in read receipts
This commit is contained in:
parent
18ea5af45e
commit
2ce9947130
2 changed files with 10 additions and 4 deletions
|
@ -525,6 +525,8 @@ func (mx *MatrixHandler) HandleReceipt(evt *event.Event) {
|
||||||
} else if val, ok := receipt.Extra[doublePuppetKey].(string); ok && customPuppet != nil && val == doublePuppetValue {
|
} else if val, ok := receipt.Extra[doublePuppetKey].(string); ok && customPuppet != nil && val == doublePuppetValue {
|
||||||
// Ignore double puppeted read receipts.
|
// Ignore double puppeted read receipts.
|
||||||
user.log.Debugfln("Ignoring double puppeted read receipt %+v", evt.Content.Raw)
|
user.log.Debugfln("Ignoring double puppeted read receipt %+v", evt.Content.Raw)
|
||||||
|
// But do start disappearing messages, because the user read the chat
|
||||||
|
portal.ScheduleDisappearing()
|
||||||
} else {
|
} else {
|
||||||
portal.HandleMatrixReadReceipt(user, eventID, time.UnixMilli(receipt.Timestamp))
|
portal.HandleMatrixReadReceipt(user, eventID, time.UnixMilli(receipt.Timestamp))
|
||||||
}
|
}
|
||||||
|
|
12
user.go
12
user.go
|
@ -654,8 +654,8 @@ func (user *User) updateChatTag(intent *appservice.IntentAPI, portal *Portal, ta
|
||||||
}
|
}
|
||||||
|
|
||||||
type CustomReadReceipt struct {
|
type CustomReadReceipt struct {
|
||||||
Timestamp int64 `json:"ts,omitempty"`
|
Timestamp int64 `json:"ts,omitempty"`
|
||||||
DoublePuppet bool `json:"fi.mau.double_puppet_source,omitempty"`
|
DoublePuppetSource string `json:"fi.mau.double_puppet_source,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) syncChatDoublePuppetDetails(portal *Portal, justCreated bool) {
|
func (user *User) syncChatDoublePuppetDetails(portal *Portal, justCreated bool) {
|
||||||
|
@ -870,8 +870,12 @@ func (user *User) handleReceipt(receipt *events.Receipt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
intent := user.bridge.GetPuppetByJID(receipt.Sender).IntentFor(portal)
|
intent := user.bridge.GetPuppetByJID(receipt.Sender).IntentFor(portal)
|
||||||
|
var rrContent CustomReadReceipt
|
||||||
|
if intent.IsCustomPuppet {
|
||||||
|
rrContent.DoublePuppetSource = doublePuppetValue
|
||||||
|
}
|
||||||
for _, msg := range markAsRead {
|
for _, msg := range markAsRead {
|
||||||
err := intent.MarkReadWithContent(portal.MXID, msg.MXID, &CustomReadReceipt{DoublePuppet: intent.IsCustomPuppet})
|
err := intent.MarkReadWithContent(portal.MXID, msg.MXID, &rrContent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
user.log.Warnfln("Failed to mark message %s as read by %s: %v", msg.MXID, intent.UserID, err)
|
user.log.Warnfln("Failed to mark message %s as read by %s: %v", msg.MXID, intent.UserID, err)
|
||||||
} else {
|
} else {
|
||||||
|
@ -890,7 +894,7 @@ func (user *User) markSelfReadFull(portal *Portal) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
user.SetLastReadTS(portal.Key, lastMessage.Timestamp)
|
user.SetLastReadTS(portal.Key, lastMessage.Timestamp)
|
||||||
err := puppet.CustomIntent().MarkReadWithContent(portal.MXID, lastMessage.MXID, &CustomReadReceipt{DoublePuppet: true})
|
err := puppet.CustomIntent().MarkReadWithContent(portal.MXID, lastMessage.MXID, &CustomReadReceipt{DoublePuppetSource: doublePuppetValue})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
user.log.Warnfln("Failed to mark %s (last message) in %s as read: %v", lastMessage.MXID, portal.MXID, err)
|
user.log.Warnfln("Failed to mark %s (last message) in %s as read: %v", lastMessage.MXID, portal.MXID, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue