status-go/protocol/requests/send_one_to_one_message.go

30 lines
632 B
Go
Raw Permalink Normal View History

2022-10-14 08:50:36 +00:00
package requests
import (
"errors"
)
var ErrSendOneToOneMessageInvalidID = errors.New("send-one-to-one-message: invalid id")
var ErrSendOneToOneMessageInvalidMessage = errors.New("send-one-to-one-message: invalid message")
type SendOneToOneMessage struct {
ID string `json:"id"`
Message string `json:"message"`
}
func (a *SendOneToOneMessage) Validate() error {
if len(a.ID) == 0 {
return ErrSendOneToOneMessageInvalidID
}
if len(a.Message) == 0 {
return ErrSendOneToOneMessageInvalidMessage
}
return nil
}
func (a *SendOneToOneMessage) HexID() (string, error) {
return ConvertCompressedToLegacyKey(a.ID)
}