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 {
isEdit = false
} else if i == 0 {
part.Content.SetEdit(dbMsg.MXID)
part.Extra = map[string]any{
"m.new_content": part.Extra,
}
part.SetEdit(dbMsg.MXID)
} else if existingPart, ok := dbMsg.Status.MediaParts[part.ID]; ok {
part.Content.SetEdit(existingPart.EventID)
part.Extra = map[string]any{
"m.new_content": part.Extra,
}
part.SetEdit(existingPart.EventID)
} else {
ts = converted.Timestamp.UnixMilli()
isEdit = false
@ -790,6 +784,15 @@ type ConvertedMessagePart struct {
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 {
ID string
SenderID string