Mark incoming own messages as read after bridging
This commit is contained in:
parent
a42c7bca17
commit
91bab528f3
13
portal.go
13
portal.go
|
@ -678,6 +678,7 @@ func (portal *Portal) handleMessage(source *User, evt *events.Message) {
|
||||||
converted.Extra["fi.mau.whatsapp.source_broadcast_list"] = evt.Info.Chat.String()
|
converted.Extra["fi.mau.whatsapp.source_broadcast_list"] = evt.Info.Chat.String()
|
||||||
}
|
}
|
||||||
var eventID id.EventID
|
var eventID id.EventID
|
||||||
|
var lastEventID id.EventID
|
||||||
if existingMsg != nil {
|
if existingMsg != nil {
|
||||||
portal.MarkDisappearing(existingMsg.MXID, converted.ExpiresIn, false)
|
portal.MarkDisappearing(existingMsg.MXID, converted.ExpiresIn, false)
|
||||||
converted.Content.SetEdit(existingMsg.MXID)
|
converted.Content.SetEdit(existingMsg.MXID)
|
||||||
|
@ -690,6 +691,7 @@ func (portal *Portal) handleMessage(source *User, evt *events.Message) {
|
||||||
} else {
|
} else {
|
||||||
portal.MarkDisappearing(resp.EventID, converted.ExpiresIn, false)
|
portal.MarkDisappearing(resp.EventID, converted.ExpiresIn, false)
|
||||||
eventID = resp.EventID
|
eventID = resp.EventID
|
||||||
|
lastEventID = eventID
|
||||||
}
|
}
|
||||||
// TODO figure out how to handle captions with undecryptable messages turning decryptable
|
// TODO figure out how to handle captions with undecryptable messages turning decryptable
|
||||||
if converted.Caption != nil && existingMsg == nil {
|
if converted.Caption != nil && existingMsg == nil {
|
||||||
|
@ -698,7 +700,7 @@ func (portal *Portal) handleMessage(source *User, evt *events.Message) {
|
||||||
portal.log.Errorfln("Failed to send caption of %s to Matrix: %v", msgID, err)
|
portal.log.Errorfln("Failed to send caption of %s to Matrix: %v", msgID, err)
|
||||||
} else {
|
} else {
|
||||||
portal.MarkDisappearing(resp.EventID, converted.ExpiresIn, false)
|
portal.MarkDisappearing(resp.EventID, converted.ExpiresIn, false)
|
||||||
//eventID = resp.EventID
|
lastEventID = resp.EventID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if converted.MultiEvent != nil && existingMsg == nil {
|
if converted.MultiEvent != nil && existingMsg == nil {
|
||||||
|
@ -708,9 +710,18 @@ func (portal *Portal) handleMessage(source *User, evt *events.Message) {
|
||||||
portal.log.Errorfln("Failed to send sub-event %d of %s to Matrix: %v", index+1, msgID, err)
|
portal.log.Errorfln("Failed to send sub-event %d of %s to Matrix: %v", index+1, msgID, err)
|
||||||
} else {
|
} else {
|
||||||
portal.MarkDisappearing(resp.EventID, converted.ExpiresIn, false)
|
portal.MarkDisappearing(resp.EventID, converted.ExpiresIn, false)
|
||||||
|
lastEventID = resp.EventID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if source.MXID == intent.UserID {
|
||||||
|
// There are some edge cases (like call notices) where previous messages aren't marked as read
|
||||||
|
// when the user sends a message from another device, so just mark the new message as read to be safe.
|
||||||
|
err = intent.SetReadMarkers(portal.MXID, makeReadMarkerContent(lastEventID, true))
|
||||||
|
if err != nil {
|
||||||
|
portal.log.Warnfln("Failed to mark own message %s as read by %s: %v", lastEventID, source.MXID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
if len(eventID) != 0 {
|
if len(eventID) != 0 {
|
||||||
portal.finishHandling(existingMsg, &evt.Info, eventID, database.MsgNormal, converted.Error)
|
portal.finishHandling(existingMsg, &evt.Info, eventID, database.MsgNormal, converted.Error)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue