2021-05-14 21:22:50 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/ecdsa"
|
|
|
|
|
|
|
|
"github.com/golang/protobuf/proto"
|
|
|
|
|
|
|
|
"github.com/status-im/status-go/protocol/protobuf"
|
|
|
|
)
|
|
|
|
|
2022-09-20 09:13:44 +00:00
|
|
|
type PinnedMessages []*PinnedMessage
|
|
|
|
|
|
|
|
func (m PinnedMessages) GetClock(i int) uint64 {
|
|
|
|
return m[i].Message.Clock
|
|
|
|
}
|
|
|
|
|
2021-05-14 21:22:50 +00:00
|
|
|
type PinMessage struct {
|
|
|
|
protobuf.PinMessage
|
|
|
|
|
|
|
|
// ID calculated as keccak256(compressedAuthorPubKey, data) where data is unencrypted payload.
|
|
|
|
ID string `json:"id"`
|
|
|
|
// MessageID string `json:"messageID"`
|
|
|
|
// WhisperTimestamp is a timestamp of a Whisper envelope.
|
|
|
|
WhisperTimestamp uint64 `json:"whisperTimestamp"`
|
|
|
|
// From is a public key of the user who pinned the message.
|
|
|
|
From string `json:"from"`
|
|
|
|
// The chat id to be stored locally
|
|
|
|
LocalChatID string `json:"localChatId"`
|
|
|
|
SigPubKey *ecdsa.PublicKey `json:"-"`
|
|
|
|
// Identicon of the author
|
|
|
|
Identicon string `json:"identicon"`
|
|
|
|
// Random 3 words name
|
|
|
|
Alias string `json:"alias"`
|
2023-04-17 14:44:48 +00:00
|
|
|
|
|
|
|
Message *PinnedMessage `json:"pinnedMessage"`
|
2021-05-14 21:22:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PinnedMessage struct {
|
2021-06-08 15:23:32 +00:00
|
|
|
Message *Message `json:"message"`
|
|
|
|
PinnedAt uint64 `json:"pinnedAt"`
|
|
|
|
PinnedBy string `json:"pinnedBy"`
|
2021-05-14 21:22:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// WrapGroupMessage indicates whether we should wrap this in membership information
|
|
|
|
func (m *PinMessage) WrapGroupMessage() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetMessageType a setter for the MessageType field
|
|
|
|
// this function is required to implement the ChatEntity interface
|
|
|
|
func (m *PinMessage) SetMessageType(messageType protobuf.MessageType) {
|
|
|
|
m.MessageType = messageType
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *PinMessage) GetGrant() []byte {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetProtoBuf returns the struct's embedded protobuf struct
|
|
|
|
// this function is required to implement the ChatEntity interface
|
|
|
|
func (m *PinMessage) GetProtobuf() proto.Message {
|
|
|
|
return &m.PinMessage
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSigPubKey returns an ecdsa encoded public key
|
|
|
|
// this function is required to implement the ChatEntity interface
|
|
|
|
func (m PinMessage) GetSigPubKey() *ecdsa.PublicKey {
|
|
|
|
return m.SigPubKey
|
|
|
|
}
|