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
76 lines
3.3 KiB
Go
76 lines
3.3 KiB
Go
package common
|
|
|
|
import (
|
|
"crypto/ecdsa"
|
|
|
|
"github.com/status-im/status-go/internal/protocol/protobuf"
|
|
messagingtypes "github.com/status-im/status-go/pkg/messaging/types"
|
|
)
|
|
|
|
// RawMessage represent a sent or received message, kept for being able
|
|
// to re-send/propagate
|
|
type RawMessage struct {
|
|
ID string
|
|
LocalChatID string
|
|
LastSent uint64
|
|
SendCount int
|
|
Sent bool
|
|
// SkipEncryptionLayer instructs the sender to bypass the encryption-layer protobuf wrapper.
|
|
// Both public and private messages normally include that wrapper so the X3DH bundle travels with
|
|
// them, though only private messages encrypt their payload.
|
|
// Use this when the message must avoid exposing our bundle (e.g. anonymous sends or publishing with
|
|
// a non-identity key).
|
|
// With this flag set, MVDS resends are unavailable because they require encrypted
|
|
// payloads, but RawMessage-based retries remain possible via ResendTypeRawMessage.
|
|
SkipEncryptionLayer bool
|
|
SendPushNotification bool
|
|
MessageType protobuf.ApplicationMetadataMessage_Type
|
|
Payload []byte
|
|
Sender *ecdsa.PrivateKey
|
|
Recipients []*ecdsa.PublicKey
|
|
SkipGroupMessageWrap bool
|
|
SkipApplicationWrap bool
|
|
SendOnPersonalTopic bool
|
|
CommunityID []byte
|
|
CommunityKeyExMsgType messagingtypes.CommKeyExMsgType
|
|
Ephemeral bool
|
|
BeforeDispatch func(*RawMessage) error
|
|
HashRatchetGroupID []byte
|
|
ContentTopic string
|
|
PubsubTopic string
|
|
ResendType ResendType
|
|
ResendMethod ResendMethod
|
|
Priority *messagingtypes.MessagePriority
|
|
}
|
|
|
|
// ResendType There are distinct mechanisms for retrying send messages: Datasync supports only direct messages (1-to-1 or private group chats)
|
|
// because it requires an acknowledgment (ACK). As implemented, sending a message to a community, where hundreds of
|
|
// people receive it, would lead all recipients to attempt sending an ACK, resulting in an excessive number of messages.
|
|
// Datasync utilizes ACKs, but community messages do not, to avoid this issue. However, we still aim to retry sending
|
|
// community messages if they fail to send or if we are offline.
|
|
type ResendType uint8
|
|
|
|
const (
|
|
// ResendTypeNone won't resend
|
|
ResendTypeNone ResendType = 0
|
|
// ResendTypeDataSync use DataSync which use MVDS as underlying dependency to resend messages.
|
|
// Works only when underlying sending method is MessageSender#SendPrivate. Pls see SendPrivate for more details.
|
|
// For usage example, you can find usage with this type value in this project. e.g. Messenger#syncContact
|
|
ResendTypeDataSync ResendType = 1
|
|
// ResendTypeRawMessage We have a function, watchExpiredMessages, that monitors the 'raw_messages' table
|
|
// and will attempts to resend messages if a previous message sending failed.
|
|
ResendTypeRawMessage ResendType = 2
|
|
)
|
|
|
|
// ResendMethod defines how to resend a raw message
|
|
type ResendMethod uint8
|
|
|
|
const (
|
|
// ResendMethodDynamic determined by logic of Messenger#dispatchMessage, mostly based on chat type
|
|
ResendMethodDynamic ResendMethod = 0
|
|
// ResendMethodSendPrivate corresponding function MessageSender#SendPrivate
|
|
ResendMethodSendPrivate ResendMethod = 1
|
|
// ResendMethodSendCommunityMessage corresponding function MessageSender#SendCommunityMessage
|
|
ResendMethodSendCommunityMessage ResendMethod = 2
|
|
)
|