github.com/status-im/status-go@v1.1.0/protocol/common/pin_message.go (about) 1 package common 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 type PinnedMessages []*PinnedMessage 12 13 func (m PinnedMessages) GetClock(i int) uint64 { 14 return m[i].Message.Clock 15 } 16 17 type PinMessage struct { 18 *protobuf.PinMessage 19 20 // ID calculated as keccak256(compressedAuthorPubKey, data) where data is unencrypted payload. 21 ID string `json:"id"` 22 // MessageID string `json:"messageID"` 23 // WhisperTimestamp is a timestamp of a Whisper envelope. 24 WhisperTimestamp uint64 `json:"whisperTimestamp"` 25 // From is a public key of the user who pinned the message. 26 From string `json:"from"` 27 // The chat id to be stored locally 28 LocalChatID string `json:"localChatId"` 29 SigPubKey *ecdsa.PublicKey `json:"-"` 30 // Identicon of the author 31 Identicon string `json:"identicon"` 32 // Random 3 words name 33 Alias string `json:"alias"` 34 35 Message *PinnedMessage `json:"pinnedMessage"` 36 } 37 38 func NewPinMessage() *PinMessage { 39 return &PinMessage{PinMessage: &protobuf.PinMessage{}} 40 } 41 42 type PinnedMessage struct { 43 Message *Message `json:"message"` 44 PinnedAt uint64 `json:"pinnedAt"` 45 PinnedBy string `json:"pinnedBy"` 46 } 47 48 // WrapGroupMessage indicates whether we should wrap this in membership information 49 func (m *PinMessage) WrapGroupMessage() bool { 50 return false 51 } 52 53 // SetMessageType a setter for the MessageType field 54 // this function is required to implement the ChatEntity interface 55 func (m *PinMessage) SetMessageType(messageType protobuf.MessageType) { 56 m.MessageType = messageType 57 } 58 59 // GetProtoBuf returns the struct's embedded protobuf struct 60 // this function is required to implement the ChatEntity interface 61 func (m *PinMessage) GetProtobuf() proto.Message { 62 return m.PinMessage 63 } 64 65 // GetSigPubKey returns an ecdsa encoded public key 66 // this function is required to implement the ChatEntity interface 67 func (m *PinMessage) GetSigPubKey() *ecdsa.PublicKey { 68 return m.SigPubKey 69 }