Validate edit
This commit is contained in:
parent
e68fad2788
commit
c18d827d54
|
@ -39,6 +39,24 @@ func ValidateMembershipUpdateMessage(message *protocol.MembershipUpdateMessage,
|
|||
return nil
|
||||
}
|
||||
|
||||
func ValidateEditMessage(message protobuf.EditMessage) error {
|
||||
if message.Clock == 0 {
|
||||
return errors.New("clock can't be 0")
|
||||
}
|
||||
if len(message.ChatId) == 0 {
|
||||
return errors.New("chat-id can't be empty")
|
||||
}
|
||||
if len(message.MessageId) == 0 {
|
||||
return errors.New("message-id can't be empty")
|
||||
}
|
||||
|
||||
if message.MessageType == protobuf.MessageType_UNKNOWN_MESSAGE_TYPE || message.MessageType == protobuf.MessageType_SYSTEM_MESSAGE_PRIVATE_GROUP {
|
||||
return errors.New("unknown message type")
|
||||
}
|
||||
|
||||
return ValidateText(message.Text)
|
||||
}
|
||||
|
||||
func ValidateReceivedPairInstallation(message *protobuf.PairInstallation, whisperTimestamp uint64) error {
|
||||
if err := validateClockValue(message.Clock, whisperTimestamp); err != nil {
|
||||
return err
|
||||
|
|
|
@ -490,6 +490,9 @@ func (m *Messenger) handleWrappedCommunityDescriptionMessage(payload []byte) (*c
|
|||
}
|
||||
|
||||
func (m *Messenger) HandleEditMessage(response *MessengerResponse, editMessage EditMessage) error {
|
||||
if err := ValidateEditMessage(editMessage.EditMessage); err != nil {
|
||||
return err
|
||||
}
|
||||
messageID := editMessage.MessageId
|
||||
// Check if it's already in the response
|
||||
originalMessage := response.GetMessage(messageID)
|
||||
|
|
Loading…
Reference in New Issue