github.com/status-im/status-go@v1.1.0/protocol/edit_message.go (about)

     1  package protocol
     2  
     3  import (
     4  	"crypto/ecdsa"
     5  
     6  	"github.com/golang/protobuf/proto"
     7  
     8  	"github.com/status-im/status-go/protocol/protobuf"
     9  )
    10  
    11  // EditMessage represents an edit of a message from a user in the application layer, used for persistence, querying and
    12  // signaling
    13  type EditMessage struct {
    14  	*protobuf.EditMessage
    15  
    16  	// ID is the ID of the message that has been edited
    17  	ID string `json:"id,omitempty"`
    18  
    19  	// From is a public key of the author of the edit reaction.
    20  	From string `json:"from,omitempty"`
    21  
    22  	// SigPubKey is the ecdsa encoded public key of the edit author
    23  	SigPubKey *ecdsa.PublicKey `json:"-"`
    24  
    25  	// LocalChatID is the chatID of the local chat (one-to-one are not symmetric)
    26  	LocalChatID string `json:"localChatId"`
    27  }
    28  
    29  func NewEditMessage() *EditMessage {
    30  	return &EditMessage{EditMessage: &protobuf.EditMessage{}}
    31  }
    32  
    33  // GetSigPubKey returns an ecdsa encoded public key
    34  // this function is required to implement the ChatEntity interface
    35  func (e *EditMessage) GetSigPubKey() *ecdsa.PublicKey {
    36  	return e.SigPubKey
    37  }
    38  
    39  // GetProtoBuf returns the struct's embedded protobuf struct
    40  // this function is required to implement the ChatEntity interface
    41  func (e *EditMessage) GetProtobuf() proto.Message {
    42  	return e.EditMessage
    43  }
    44  
    45  // SetMessageType a setter for the MessageType field
    46  // this function is required to implement the ChatEntity interface
    47  func (e *EditMessage) SetMessageType(messageType protobuf.MessageType) {
    48  	e.MessageType = messageType
    49  }
    50  
    51  // WrapGroupMessage indicates whether we should wrap this in membership information
    52  func (e *EditMessage) WrapGroupMessage() bool {
    53  	return false
    54  }