Fix handling updates to multipart messages

This commit is contained in:
Tulir Asokan 2023-09-04 11:33:03 +03:00
parent a947eddcee
commit 53e992c25d

View file

@ -507,15 +507,9 @@ func (portal *Portal) handleExistingMessageUpdate(ctx context.Context, source *U
if chatIDChanged { if chatIDChanged {
isEdit = false isEdit = false
} else if i == 0 { } else if i == 0 {
part.Content.SetEdit(dbMsg.MXID) part.SetEdit(dbMsg.MXID)
part.Extra = map[string]any{
"m.new_content": part.Extra,
}
} else if existingPart, ok := dbMsg.Status.MediaParts[part.ID]; ok { } else if existingPart, ok := dbMsg.Status.MediaParts[part.ID]; ok {
part.Content.SetEdit(existingPart.EventID) part.SetEdit(existingPart.EventID)
part.Extra = map[string]any{
"m.new_content": part.Extra,
}
} else { } else {
ts = converted.Timestamp.UnixMilli() ts = converted.Timestamp.UnixMilli()
isEdit = false isEdit = false
@ -790,6 +784,15 @@ type ConvertedMessagePart struct {
Extra map[string]any Extra map[string]any
} }
func (cmp *ConvertedMessagePart) SetEdit(eventID id.EventID) {
cmp.Content.SetEdit(eventID)
if cmp.Extra != nil {
cmp.Extra = map[string]any{
"m.new_content": cmp.Extra,
}
}
}
type ConvertedMessage struct { type ConvertedMessage struct {
ID string ID string
SenderID string SenderID string