diff --git a/matrix.go b/matrix.go index 6982a25..24ee728 100644 --- a/matrix.go +++ b/matrix.go @@ -525,6 +525,8 @@ func (mx *MatrixHandler) HandleReceipt(evt *event.Event) { } else if val, ok := receipt.Extra[doublePuppetKey].(string); ok && customPuppet != nil && val == doublePuppetValue { // Ignore double puppeted read receipts. 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 { portal.HandleMatrixReadReceipt(user, eventID, time.UnixMilli(receipt.Timestamp)) } diff --git a/user.go b/user.go index 7d102a1..a059818 100644 --- a/user.go +++ b/user.go @@ -654,8 +654,8 @@ func (user *User) updateChatTag(intent *appservice.IntentAPI, portal *Portal, ta } type CustomReadReceipt struct { - Timestamp int64 `json:"ts,omitempty"` - DoublePuppet bool `json:"fi.mau.double_puppet_source,omitempty"` + Timestamp int64 `json:"ts,omitempty"` + DoublePuppetSource string `json:"fi.mau.double_puppet_source,omitempty"` } 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) + var rrContent CustomReadReceipt + if intent.IsCustomPuppet { + rrContent.DoublePuppetSource = doublePuppetValue + } 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 { user.log.Warnfln("Failed to mark message %s as read by %s: %v", msg.MXID, intent.UserID, err) } else { @@ -890,7 +894,7 @@ func (user *User) markSelfReadFull(portal *Portal) { return } 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 { user.log.Warnfln("Failed to mark %s (last message) in %s as read: %v", lastMessage.MXID, portal.MXID, err) }