mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 06:12:55 +00:00
b01a861e8e
This adds a new `DiscordMessageAttachment` type which is part of `DiscordMessage`. Along with that type, there's also a new database table for `discord_message_attachments` and corresponding persistence APIs. This commit also changes how chat messages are retrieved. Here's why: `DiscordMessage` can have multiple `DiscordMessageAttachment`. A chat message can have a `DiscordMessage`. Because we're `LEFT JOIN`'ing the discord message attachments into the chat messages, there's a possibility of multiple rows per message. Hence, this commit ensures we collect queried discord message attachments on chat messages.
68 lines
1.8 KiB
Go
68 lines
1.8 KiB
Go
package common
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
|
|
"github.com/golang/protobuf/proto"
|
|
|
|
"github.com/status-im/status-go/protocol/protobuf"
|
|
)
|
|
|
|
type PinnedMessages []*PinnedMessage
|
|
|
|
func (m PinnedMessages) GetClock(i int) uint64 {
|
|
return m[i].Message.Clock
|
|
}
|
|
|
|
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"`
|
|
}
|
|
|
|
type PinnedMessage struct {
|
|
Message *Message `json:"message"`
|
|
PinnedAt uint64 `json:"pinnedAt"`
|
|
PinnedBy string `json:"pinnedBy"`
|
|
}
|
|
|
|
// 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
|
|
}
|