mirror of
https://github.com/status-im/status-go.git
synced 2026-08-31 00:51:12 +00:00
Part of the Go project layout migration, item 27. Pure move plus import-path rewrite across 502 files. No API or behaviour change. `internal/` keeps the messaging application logic unimportable from outside the module, which is what the issue asks for -- status-go is consumed through the C-bindings in mobile/, not as a Go library. Things that had to follow the move, beyond the Go imports: - tools/generate-handlers/template.txt. messenger_handlers.go is generated, and the template hard-codes the imports it emits, so the generated file kept importing protocol/common and failed typecheck. - .gitignore. The ignore rule for that generated file was pinned to the old path; without moving it, a 1486-line generated file starts being tracked. - Makefile: the logosstorage and torrent test targets (both the archive packages and ./protocol itself), the archive README, migration-protocol. - scripts/run_unit_tests.sh, which names the protocol package explicitly to shard its tests. - scripts/cleanup_generated_files.sh and .golangci.yml. scripts/migration_check.sh also needed a fix that is not specific to this move: it validated every file the branch touched under a migration dir against the timestamp naming rule, and a directory rename makes every migration in it look newly added. It now excludes renames, so moving a migration is not mistaken for adding one. refs #7067
68 lines
1.9 KiB
Go
68 lines
1.9 KiB
Go
package common
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
|
|
"github.com/golang/protobuf/proto"
|
|
|
|
"github.com/status-im/status-go/internal/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:"-"`
|
|
// Random 3 words name
|
|
Alias string `json:"alias"`
|
|
|
|
Message *PinnedMessage `json:"pinnedMessage"`
|
|
}
|
|
|
|
func NewPinMessage() *PinMessage {
|
|
return &PinMessage{PinMessage: &protobuf.PinMessage{}}
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
// 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
|
|
}
|