status-go/protocol/requests/edit_message.go
Jonathan Rainville 92ba63b282
fix(edit)_: make sure the contentType stays the same after an edit (#6133)
Fixes https://github.com/status-im/status-desktop/issues/16741

The issue was that in image messages, you can update the text, but then the ContentType would become Text and lose the image.
The solution is to ignore ContentType changes, since there is no way to change the type of message.
2024-12-03 10:04:21 -05:00

31 lines
751 B
Go

package requests
import (
"errors"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/common"
)
var ErrEditMessageInvalidID = errors.New("edit-message: invalid id")
var ErrEditMessageInvalidText = errors.New("edit-message: invalid text")
type EditMessage struct {
ID types.HexBytes `json:"id"`
Text string `json:"text"`
LinkPreviews []common.LinkPreview `json:"linkPreviews"`
StatusLinkPreviews []common.StatusLinkPreview `json:"statusLinkPreviews"`
}
func (e *EditMessage) Validate() error {
if len(e.ID) == 0 {
return ErrEditMessageInvalidID
}
if len(e.Text) == 0 {
return ErrEditMessageInvalidText
}
return nil
}