common

package
v0.182.43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2024 License: MPL-2.0, MPL-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OutgoingStatusSending   = "sending"
	OutgoingStatusSent      = "sent"
	OutgoingStatusDelivered = "delivered"
)
View Source
const (
	MessageScheduled = iota + 1
	MessageSent
)
View Source
const EveryoneMentionTag = "0x00001"

Variables

View Source
var (
	ErrInvalidCiphertextLength = errors.New("invalid cyphertext length")
)
View Source
var ErrMessageSegmentsAlreadyCompleted = errors.New("message segments already completed")
View Source
var ErrMessageSegmentsHashMismatch = errors.New("hash of entire payload does not match")
View Source
var ErrMessageSegmentsIncomplete = errors.New("message segments incomplete")
View Source
var ErrMessageSegmentsInvalidCount = errors.New("invalid segments count")
View Source
var ErrMessageSegmentsInvalidParity = errors.New("invalid parity segments")
View Source
var ErrModifiedRawMessage = errors.New("modified rawMessage")
View Source
var ErrRecordNotFound = errors.New("record not found")
View Source
var RekeyCompatibility = true

RekeyCompatibility indicates whether we should be sending keys in 1-to-1 messages as well as in the newer format

Functions

func Decrypt

func Decrypt(cyphertext []byte, key []byte) ([]byte, error)

func Encrypt

func Encrypt(plaintext []byte, key []byte, reader io.Reader) ([]byte, error)

func HashPublicKey

func HashPublicKey(pk *ecdsa.PublicKey) []byte

func HexToPubkey added in v0.67.0

func HexToPubkey(pk string) (*ecdsa.PublicKey, error)

func IsPubKeyEqual

func IsPubKeyEqual(a, b *ecdsa.PublicKey) bool

IsPubKeyEqual checks that two public keys are equal

func MakeECDHSharedKey added in v0.89.2

func MakeECDHSharedKey(yourPrivateKey *ecdsa.PrivateKey, theirPubKey *ecdsa.PublicKey) ([]byte, error)

func MessageSpecToWhisper

func MessageSpecToWhisper(spec *encryption.ProtocolMessageSpec) (*types.NewMessage, error)

func PubkeyToHex added in v0.67.0

func PubkeyToHex(key *ecdsa.PublicKey) string

func PubkeyToHexBytes added in v0.72.0

func PubkeyToHexBytes(key *ecdsa.PublicKey) types.HexBytes

func PubkeysToHex added in v0.181.31

func PubkeysToHex(keys []*ecdsa.PublicKey) []string

func RandomAlphabeticalString added in v0.115.4

func RandomAlphabeticalString(n int) (string, error)

func RandomAlphanumericString added in v0.115.4

func RandomAlphanumericString(n int) (string, error)

func Shake256

func Shake256(buf []byte) []byte

func ShouldCommunityMessageBeEncrypted added in v0.117.3

func ShouldCommunityMessageBeEncrypted(msgType protobuf.ApplicationMetadataMessage_Type) bool

Types

type ChatEntity added in v0.56.4

type ChatEntity interface {
	proto.Message

	GetChatId() string
	GetMessageType() protobuf.MessageType
	GetSigPubKey() *ecdsa.PublicKey
	GetProtobuf() proto.Message
	WrapGroupMessage() bool

	SetMessageType(messageType protobuf.MessageType)
}

ChatEntity is anything that is sendable in a chat. Currently it encompass a Message and EmojiReaction.

type CodeControlFlags added in v0.176.7

type CodeControlFlags struct {
	// AutoRequestHistoricMessages indicates whether we should automatically request
	// historic messages on getting online, connecting to store node, etc.
	AutoRequestHistoricMessages bool

	// CuratedCommunitiesUpdateLoopEnabled indicates whether we should disable the curated communities update loop.
	// Usually should be disabled in tests.
	CuratedCommunitiesUpdateLoopEnabled bool
}

type CommKeyExMsgType added in v0.102.2

type CommKeyExMsgType uint8
const (
	KeyExMsgNone  CommKeyExMsgType = 0
	KeyExMsgReuse CommKeyExMsgType = 1
	KeyExMsgRekey CommKeyExMsgType = 2
)

type CommandParameters added in v0.61.0

type CommandParameters struct {
	// ID is the ID of the initial message
	ID string `json:"id"`
	// From is the address we are sending the command from
	From string `json:"from"`
	// Address is the address sent with the command
	Address string `json:"address"`
	// Contract is the contract address for ERC20 tokens
	Contract string `json:"contract"`
	// Value is the value as a string sent
	Value string `json:"value"`
	// TransactionHash is the hash of the transaction
	TransactionHash string `json:"transactionHash"`
	// CommandState is the state of the command
	CommandState CommandState `json:"commandState"`
	// The Signature of the pk-bytes+transaction-hash from the wallet
	// address originating
	Signature []byte `json:"signature"`
}

func (*CommandParameters) IsTokenTransfer added in v0.61.0

func (c *CommandParameters) IsTokenTransfer() bool

type CommandState added in v0.61.0

type CommandState int
const (
	CommandStateRequestAddressForTransaction CommandState = iota + 1
	CommandStateRequestAddressForTransactionDeclined
	CommandStateRequestAddressForTransactionAccepted
	CommandStateRequestTransaction
	CommandStateRequestTransactionDeclined
	CommandStateTransactionPending
	CommandStateTransactionSent
)

type ContactRequestState added in v0.100.0

type ContactRequestState int
const (
	ContactRequestStatePending ContactRequestState = iota + 1
	ContactRequestStateAccepted
	ContactRequestStateDismissed
)

type ContactVerificationState added in v0.113.0

type ContactVerificationState int
const (
	ContactVerificationStatePending ContactVerificationState = iota + 1
	ContactVerificationStateAccepted
	ContactVerificationStateDeclined
	ContactVerificationStateTrusted
	ContactVerificationStateUntrustworthy
	ContactVerificationStateCanceled
)

type DatasyncOffer added in v0.172.10

type DatasyncOffer struct {
	GroupID   []byte
	MessageID []byte
}

type FeatureFlags

type FeatureFlags struct {
	// Datasync indicates whether direct messages should be sent exclusively
	// using datasync, breaking change for non-v1 clients. Public messages
	// are not impacted
	Datasync bool

	// PushNotification indicates whether we should be enabling the push notification feature
	PushNotifications bool

	// MailserverCycle indicates whether we should enable or not the mailserver cycle
	MailserverCycle bool

	// DisableCheckingForBackup disables backup loop
	DisableCheckingForBackup bool

	// DisableAutoMessageLoop disables auto message loop
	DisableAutoMessageLoop bool

	// ResendRawMessagesDisabled indicates whether we should be disabling sending raw messages
	ResendRawMessagesDisabled bool

	// StoreNodesDisabled indicates whether we should fetch messages from store nodes
	StoreNodesDisabled bool

	// Peersyncing indicates whether we should advertise and sync messages with other peers
	Peersyncing bool

	// EnableCelerBridge indicates whether we should enable the Celer bridge in the Router
	EnableCelerBridge bool
}

type GapParameters added in v0.79.0

type GapParameters struct {
	From uint32 `json:"from,omitempty"`
	To   uint32 `json:"to,omitempty"`
}

GapParameters is the From and To indicating the missing period in chat history

type HandleMessageResponse added in v0.171.35

type HandleMessageResponse struct {
	Hash             []byte
	StatusMessages   []*v1protocol.StatusMessage
	DatasyncSender   *ecdsa.PublicKey
	DatasyncAcks     [][]byte
	DatasyncOffers   []DatasyncOffer
	DatasyncRequests [][]byte
}

type LinkPreview added in v0.151.12

type LinkPreview struct {
	Type        protobuf.UnfurledLink_LinkType `json:"type"`
	URL         string                         `json:"url"`
	Hostname    string                         `json:"hostname"`
	Title       string                         `json:"title,omitempty"`
	Description string                         `json:"description,omitempty"`
	Favicon     LinkPreviewThumbnail           `json:"favicon,omitempty"`
	Thumbnail   LinkPreviewThumbnail           `json:"thumbnail,omitempty"`
}

type LinkPreviewThumbnail added in v0.151.12

type LinkPreviewThumbnail struct {
	Width  int `json:"width,omitempty"`
	Height int `json:"height,omitempty"`
	// Non-empty when the thumbnail is available via the media server, i.e. after
	// the chat message is sent.
	URL string `json:"url,omitempty"`
	// Non-empty when the thumbnail payload needs to be shared with the client,
	// but before it has been persisted.
	DataURI string `json:"dataUri,omitempty"`
}

func (*LinkPreviewThumbnail) IsEmpty added in v0.170.0

func (thumbnail *LinkPreviewThumbnail) IsEmpty() bool

type LinksVisitor added in v0.151.12

type LinksVisitor struct {
	Links []string
}

func RunLinksVisitor added in v0.151.12

func RunLinksVisitor(parsedText ast.Node) *LinksVisitor

func (*LinksVisitor) Visit added in v0.151.12

func (v *LinksVisitor) Visit(node ast.Node, entering bool) ast.WalkStatus

type MakeMediaServerURLMessageWrapperType added in v0.170.0

type MakeMediaServerURLMessageWrapperType func(previewURL string, imageID MediaServerImageID) string

type MakeMediaServerURLType added in v0.170.0

type MakeMediaServerURLType func(msgID string, previewURL string, imageID MediaServerImageID) string

type MediaServerImageID added in v0.170.0

type MediaServerImageID string

func CreateImageID added in v0.170.0

type MediaServerImageIDPostfix added in v0.170.0

type MediaServerImageIDPostfix string
const (
	MediaServerIconPostfix   MediaServerImageIDPostfix = "icon"
	MediaServerBannerPostfix MediaServerImageIDPostfix = "banner"
)

type MediaServerImageIDPrefix added in v0.170.0

type MediaServerImageIDPrefix string
const (
	MediaServerContactPrefix          MediaServerImageIDPrefix = "contact-"
	MediaServerCommunityPrefix        MediaServerImageIDPrefix = "community-"
	MediaServerChannelCommunityPrefix MediaServerImageIDPrefix = "community-channel-"
)

type MentionsAndLinksVisitor added in v0.74.2

type MentionsAndLinksVisitor struct {
	// contains filtered or unexported fields
}

implement interface of https://github.com/status-im/markdown/blob/b9fe921681227b1dace4b56364e15edb3b698308/ast/node.go#L701

func (*MentionsAndLinksVisitor) Visit added in v0.74.2

func (v *MentionsAndLinksVisitor) Visit(node ast.Node, entering bool) ast.WalkStatus

type Message added in v0.61.0

type Message struct {
	*protobuf.ChatMessage

	// ID calculated as keccak256(compressedAuthorPubKey, data) where data is unencrypted payload.
	ID string `json:"id"`
	// WhisperTimestamp is a timestamp of a Whisper envelope.
	WhisperTimestamp uint64 `json:"whisperTimestamp"`
	// From is a public key of the author of the message.
	From string `json:"from"`
	// Random 3 words name
	Alias string `json:"alias"`
	// Identicon of the author
	Identicon string `json:"identicon"`
	// The chat id to be stored locally
	LocalChatID string `json:"localChatId"`
	// Seen set to true when user have read this message already
	Seen           bool   `json:"seen"`
	OutgoingStatus string `json:"outgoingStatus,omitempty"`

	QuotedMessage *QuotedMessage `json:"quotedMessage"`

	// CommandParameters is the parameters sent with the message
	CommandParameters *CommandParameters `json:"commandParameters"`

	// GapParameters is the value from/to related to the gap
	GapParameters *GapParameters `json:"gapParameters,omitempty"`

	// Computed fields
	// RTL is whether this is a right-to-left message (arabic/hebrew script etc)
	RTL bool `json:"rtl"`
	// ParsedText is the parsed markdown for displaying
	ParsedText []byte `json:"parsedText,omitempty"`
	// ParsedTextAst is the ast of the parsed text
	ParsedTextAst *ast.Node `json:"-"`
	// LineCount is the count of newlines in the message
	LineCount int `json:"lineCount"`
	// Base64Image is the converted base64 image
	Base64Image string `json:"image,omitempty"`
	// ImagePath is the path of the image to be sent
	ImagePath string `json:"imagePath,omitempty"`
	// Base64Audio is the converted base64 audio
	Base64Audio string `json:"audio,omitempty"`
	// AudioPath is the path of the audio to be sent
	AudioPath string `json:"audioPath,omitempty"`
	// ImageLocalURL is the local url of the image
	ImageLocalURL string `json:"imageLocalUrl,omitempty"`
	// AudioLocalURL is the local url of the audio
	AudioLocalURL string `json:"audioLocalUrl,omitempty"`
	// StickerLocalURL is the local url of the sticker
	StickerLocalURL string `json:"stickerLocalUrl,omitempty"`

	// CommunityID is the id of the community to advertise
	CommunityID string `json:"communityId,omitempty"`

	// Replace indicates that this is a replacement of a message
	// that has been updated
	Replace string `json:"replace,omitempty"`
	New     bool   `json:"new,omitempty"`

	SigPubKey *ecdsa.PublicKey `json:"-"`

	// Mentions is an array of mentions for a given message
	Mentions []string

	// Mentioned is whether the user is mentioned in the message
	Mentioned bool `json:"mentioned"`

	// Replied is whether the user is replied to in the message
	Replied bool `json:"replied"`

	// Links is an array of links within given message
	Links              []string
	LinkPreviews       []LinkPreview       `json:"linkPreviews"`
	StatusLinkPreviews []StatusLinkPreview `json:"statusLinkPreviews"`

	// EditedAt indicates the clock value it was edited
	EditedAt uint64 `json:"editedAt"`

	// Deleted indicates if a message was deleted
	Deleted bool `json:"deleted"`

	DeletedBy string `json:"deletedBy,omitempty"`

	DeletedForMe bool `json:"deletedForMe"`

	// ContactRequestState is the state of the contact request message
	ContactRequestState ContactRequestState `json:"contactRequestState,omitempty"`

	// ContactVerificationState is the state of the identity verification process
	ContactVerificationState ContactVerificationState `json:"contactVerificationState,omitempty"`

	DiscordMessage *protobuf.DiscordMessage `json:"discordMessage,omitempty"`
}

Message represents a message record in the database, more specifically in user_messages table.

func NewMessage added in v0.163.14

func NewMessage() *Message

func (*Message) ConvertFromProtoToLinkPreviews added in v0.151.12

func (m *Message) ConvertFromProtoToLinkPreviews(makeThumbnailMediaServerURL func(msgID string, previewURL string) string,
	makeFaviconMediaServerURL func(msgID string, previewURL string) string) []LinkPreview

func (*Message) ConvertFromProtoToStatusLinkPreviews added in v0.170.0

func (m *Message) ConvertFromProtoToStatusLinkPreviews(makeMediaServerURL func(msgID string, previewURL string, imageID MediaServerImageID) string) []StatusLinkPreview

func (*Message) ConvertLinkPreviewsToProto added in v0.151.12

func (m *Message) ConvertLinkPreviewsToProto() ([]*protobuf.UnfurledLink, error)

ConvertLinkPreviewsToProto expects previews to be correctly sent by the client because we can't attempt to re-unfurl URLs at this point (it's actually undesirable). We run a basic validation as an additional safety net.

func (*Message) ConvertStatusLinkPreviewsToProto added in v0.170.0

func (m *Message) ConvertStatusLinkPreviewsToProto() (*protobuf.UnfurledStatusLinks, error)

func (*Message) GetProtobuf added in v0.61.0

func (m *Message) GetProtobuf() proto.Message

GetProtoBuf returns the struct's embedded protobuf struct this function is required to implement the ChatEntity interface

func (*Message) GetSenderPubKey added in v0.71.5

func (m *Message) GetSenderPubKey() (*ecdsa.PublicKey, error)

GetPublicKey attempts to return or recreate the *ecdsa.PublicKey of the Message sender. If the m.SigPubKey is set this will be returned If the m.From is present the string is decoded and unmarshalled into a *ecdsa.PublicKey, the m.SigPubKey is set and returned Else an error is thrown This function differs from GetSigPubKey() as this function may return an error

func (*Message) GetSigPubKey added in v0.61.0

func (m *Message) GetSigPubKey() *ecdsa.PublicKey

GetSigPubKey returns an ecdsa encoded public key this function is required to implement the ChatEntity interface

func (*Message) GetSimplifiedText added in v0.74.2

func (m *Message) GetSimplifiedText(identity string, canonicalNames map[string]string) (string, error)

GetSimplifiedText returns a the text stripped of all the markdown and with mentions replaced by canonical names

func (*Message) LoadAudio added in v0.129.3

func (m *Message) LoadAudio() error

func (*Message) LoadImage added in v0.129.3

func (m *Message) LoadImage() error

func (*Message) MarshalJSON added in v0.61.0

func (m *Message) MarshalJSON() ([]byte, error)

func (*Message) PrepareContent added in v0.61.0

func (m *Message) PrepareContent(identity string) error

PrepareContent return the parsed content of the message, the line-count and whether is a right-to-left message

func (*Message) SetAlbumIDAndImagesCount added in v0.142.9

func (m *Message) SetAlbumIDAndImagesCount(albumID string, imagesCount uint32) error

func (*Message) SetMessageType added in v0.61.0

func (m *Message) SetMessageType(messageType protobuf.MessageType)

SetMessageType a setter for the MessageType field this function is required to implement the ChatEntity interface

func (*Message) UnmarshalJSON added in v0.61.0

func (m *Message) UnmarshalJSON(data []byte) error

func (*Message) WrapGroupMessage added in v0.69.0

func (m *Message) WrapGroupMessage() bool

WrapGroupMessage indicates whether we should wrap this in membership information

type MessageEvent added in v0.89.9

type MessageEvent struct {
	Recipient   *ecdsa.PublicKey
	Type        MessageEventType
	SentMessage *SentMessage
	RawMessage  *RawMessage
}

type MessageEventType added in v0.89.9

type MessageEventType uint32

type MessagePriority added in v0.182.41

type MessagePriority = int

MessagePriority determines the ordering for publishing message

var (
	LowPriority    MessagePriority = 0
	NormalPriority MessagePriority = 1
	HighPriority   MessagePriority = 2
)

type MessageSender added in v0.80.2

type MessageSender struct {
	// contains filtered or unexported fields
}

func NewMessageSender added in v0.80.2

func NewMessageSender(
	identity *ecdsa.PrivateKey,
	database *sql.DB,
	enc *encryption.Protocol,
	transport *transport.Transport,
	logger *zap.Logger,
	features FeatureFlags,
) (*MessageSender, error)

func (*MessageSender) CleanupHashRatchetEncryptedMessages added in v0.179.19

func (s *MessageSender) CleanupHashRatchetEncryptedMessages() error

func (*MessageSender) CleanupSegments added in v0.171.21

func (s *MessageSender) CleanupSegments() error

func (*MessageSender) EncodeAbridgedMembershipUpdate added in v0.80.2

func (s *MessageSender) EncodeAbridgedMembershipUpdate(
	group *v1protocol.Group,
	chatEntity ChatEntity,
) ([]byte, error)

EncodeAbridgedMembershipUpdate takes a group and an optional chat message and returns the protobuf representation to be sent on the wire. Only the events relevant to the current group are encoded

func (*MessageSender) EncodeMembershipUpdate added in v0.80.2

func (s *MessageSender) EncodeMembershipUpdate(
	group *v1protocol.Group,
	chatEntity ChatEntity,
) ([]byte, error)

EncodeMembershipUpdate takes a group and an optional chat message and returns the protobuf representation to be sent on the wire. All the events in a group are encoded and added to the payload

func (*MessageSender) GetCurrentKeyForGroup added in v0.162.9

func (s *MessageSender) GetCurrentKeyForGroup(groupID []byte) (*encryption.HashRatchetKeyCompatibility, error)

GetCurrentKeyForGroup returns the latest key timestampID belonging to a key group

func (*MessageSender) GetEphemeralKey added in v0.181.33

func (s *MessageSender) GetEphemeralKey() (*ecdsa.PrivateKey, error)

func (*MessageSender) GetKeysForGroup added in v0.171.5

func (s *MessageSender) GetKeysForGroup(groupID []byte) ([]*encryption.HashRatchetKeyCompatibility, error)

GetKeyIDsForGroup returns a slice of key IDs belonging to a given group ID

func (*MessageSender) HandleMessages added in v0.80.2

func (s *MessageSender) HandleMessages(wakuMessage *types.Message) (*HandleMessageResponse, error)

HandleMessages expects a whisper message as input, and it will go through a series of transformations until the message is parsed into an application layer message, or in case of Raw methods, the processing stops at the layer before. It returns an error only if the processing of required steps failed.

func (*MessageSender) JoinPublic added in v0.80.2

func (s *MessageSender) JoinPublic(id string) (*transport.Filter, error)

func (*MessageSender) SendCommunityMessage added in v0.80.2

func (s *MessageSender) SendCommunityMessage(
	ctx context.Context,
	rawMessage *RawMessage,
) ([]byte, error)

SendCommunityMessage takes encoded data, encrypts it and sends through the wire using the community topic and their key

func (*MessageSender) SendGroup added in v0.80.2

func (s *MessageSender) SendGroup(
	ctx context.Context,
	recipients []*ecdsa.PublicKey,
	rawMessage RawMessage,
) ([]byte, error)

SendGroup takes encoded data, encrypts it and sends through the wire, always return the messageID

func (*MessageSender) SendMessageSpec added in v0.172.10

func (s *MessageSender) SendMessageSpec(ctx context.Context, publicKey *ecdsa.PublicKey, messageSpec *encryption.ProtocolMessageSpec, messageIDs [][]byte) ([][]byte, []*types.NewMessage, error)

func (*MessageSender) SendPairInstallation added in v0.80.2

func (s *MessageSender) SendPairInstallation(
	ctx context.Context,
	recipient *ecdsa.PublicKey,
	rawMessage RawMessage,
) ([]byte, error)

sendPairInstallation sends data to the recipients, using DH

func (*MessageSender) SendPrivate added in v0.80.2

func (s *MessageSender) SendPrivate(
	ctx context.Context,
	recipient *ecdsa.PublicKey,
	rawMessage *RawMessage,
) ([]byte, error)

SendPrivate takes encoded data, encrypts it and sends through the wire.

func (*MessageSender) SendPublic added in v0.80.2

func (s *MessageSender) SendPublic(
	ctx context.Context,
	chatName string,
	rawMessage RawMessage,
) ([]byte, error)

SendPublic takes encoded data, encrypts it and sends through the wire.

func (*MessageSender) SendPubsubTopicKey added in v0.170.0

func (s *MessageSender) SendPubsubTopicKey(
	ctx context.Context,
	rawMessage *RawMessage,
) ([]byte, error)

SendPubsubTopicKey sends the protected topic key for a community to a list of recipients

func (*MessageSender) SetHandleSharedSecrets added in v0.80.2

func (s *MessageSender) SetHandleSharedSecrets(handler func([]*sharedsecret.Secret) error)

func (*MessageSender) StartDatasync added in v0.89.20

func (s *MessageSender) StartDatasync(statusChangeEvent chan datasyncnode.PeerStatusChangeEvent, handler func(peer state.PeerID, payload *datasyncproto.Payload) error) error

func (*MessageSender) Stop added in v0.80.2

func (s *MessageSender) Stop()

func (*MessageSender) StopDatasync added in v0.89.20

func (s *MessageSender) StopDatasync()

func (*MessageSender) SubscribeToMessageEvents added in v0.89.9

func (s *MessageSender) SubscribeToMessageEvents() <-chan *MessageEvent

func (*MessageSender) ValidateRawMessage added in v0.182.38

func (s *MessageSender) ValidateRawMessage(rawMessage *RawMessage) error

type Messages added in v0.111.5

type Messages []*Message

func (Messages) GetClock added in v0.111.5

func (m Messages) GetClock(i int) uint64

type PinMessage added in v0.78.0

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"`

	Message *PinnedMessage `json:"pinnedMessage"`
}

func NewPinMessage added in v0.163.14

func NewPinMessage() *PinMessage

func (*PinMessage) GetProtobuf added in v0.78.0

func (m *PinMessage) GetProtobuf() proto.Message

GetProtoBuf returns the struct's embedded protobuf struct this function is required to implement the ChatEntity interface

func (*PinMessage) GetSigPubKey added in v0.78.0

func (m *PinMessage) GetSigPubKey() *ecdsa.PublicKey

GetSigPubKey returns an ecdsa encoded public key this function is required to implement the ChatEntity interface

func (*PinMessage) SetMessageType added in v0.78.0

func (m *PinMessage) SetMessageType(messageType protobuf.MessageType)

SetMessageType a setter for the MessageType field this function is required to implement the ChatEntity interface

func (*PinMessage) WrapGroupMessage added in v0.78.0

func (m *PinMessage) WrapGroupMessage() bool

WrapGroupMessage indicates whether we should wrap this in membership information

type PinnedMessage added in v0.78.0

type PinnedMessage struct {
	Message  *Message `json:"message"`
	PinnedAt uint64   `json:"pinnedAt"`
	PinnedBy string   `json:"pinnedBy"`
}

type PinnedMessages added in v0.111.5

type PinnedMessages []*PinnedMessage

func (PinnedMessages) GetClock added in v0.111.5

func (m PinnedMessages) GetClock(i int) uint64

type QuotedMessage added in v0.61.0

type QuotedMessage struct {
	ID          string `json:"id"`
	ContentType int64  `json:"contentType"`
	// From is a public key of the author of the message.
	From             string          `json:"from"`
	Text             string          `json:"text"`
	ParsedText       json.RawMessage `json:"parsedText,omitempty"`
	AlbumImages      json.RawMessage `json:"albumImages,omitempty"`
	AlbumImagesCount int64           `json:"albumImagesCount"`
	// ImageLocalURL is the local url of the image
	ImageLocalURL string `json:"image,omitempty"`
	// AudioLocalURL is the local url of the audio
	AudioLocalURL string `json:"audio,omitempty"`

	HasSticker bool `json:"sticker,omitempty"`
	// CommunityID is the id of the community advertised
	CommunityID string `json:"communityId,omitempty"`

	Deleted bool `json:"deleted,omitempty"`

	DeletedForMe bool `json:"deletedForMe,omitempty"`

	DiscordMessage *protobuf.DiscordMessage `json:"discordMessage,omitempty"`
	BridgeMessage  *protobuf.BridgeMessage  `json:"bridgeMessage,omitempty"`
}

QuotedMessage contains the original text of the message replied to

type RawMessage

type RawMessage struct {
	ID          string
	LocalChatID string
	LastSent    uint64
	SendCount   int
	Sent        bool
	// don't wrap message into ProtocolMessage.
	// when this is true, the message will not be resent via ResendTypeDataSync, but it's possible to
	// resend it via ResendTypeRawMessage specified in ResendType
	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 CommKeyExMsgType
	Ephemeral             bool
	BeforeDispatch        func(*RawMessage) error
	HashRatchetGroupID    []byte
	PubsubTopic           string
	ResendType            ResendType
	ResendMethod          ResendMethod
	Priority              *MessagePriority
}

RawMessage represent a sent or received message, kept for being able to re-send/propagate

type RawMessageConfirmation added in v0.73.5

type RawMessageConfirmation struct {
	// DataSyncID is the ID of the datasync message sent
	DataSyncID []byte
	// MessageID is the message id of the message
	MessageID []byte
	// PublicKey is the compressed receiver public key
	PublicKey []byte
	// ConfirmedAt is the unix timestamp in seconds of when the message was confirmed
	ConfirmedAt int64
}

type RawMessagesPersistence added in v0.73.5

type RawMessagesPersistence struct {
	// contains filtered or unexported fields
}

func NewRawMessagesPersistence added in v0.73.5

func NewRawMessagesPersistence(db *sql.DB) *RawMessagesPersistence

func (*RawMessagesPersistence) CompleteMessageSegments added in v0.171.21

func (db *RawMessagesPersistence) CompleteMessageSegments(hash []byte, sigPubKey *ecdsa.PublicKey, timestamp int64) error

func (RawMessagesPersistence) DeleteHashRatchetMessages added in v0.171.8

func (db RawMessagesPersistence) DeleteHashRatchetMessages(ids [][]byte) error

func (*RawMessagesPersistence) DeleteHashRatchetMessagesOlderThan added in v0.179.19

func (db *RawMessagesPersistence) DeleteHashRatchetMessagesOlderThan(timestamp int64) error

func (RawMessagesPersistence) GetHashRatchetMessages added in v0.111.7

func (db RawMessagesPersistence) GetHashRatchetMessages(keyID []byte) ([]*types.Message, error)

func (RawMessagesPersistence) GetHashRatchetMessagesCountForGroup added in v0.179.23

func (db RawMessagesPersistence) GetHashRatchetMessagesCountForGroup(groupID []byte) (int, error)

func (*RawMessagesPersistence) GetMessageSegments added in v0.171.21

func (db *RawMessagesPersistence) GetMessageSegments(hash []byte, sigPubKey *ecdsa.PublicKey) ([]*SegmentMessage, error)

Get ordered message segments for given hash

func (RawMessagesPersistence) InsertPendingConfirmation added in v0.73.5

func (db RawMessagesPersistence) InsertPendingConfirmation(confirmation *RawMessageConfirmation) error

func (*RawMessagesPersistence) IsMessageAlreadyCompleted added in v0.171.21

func (db *RawMessagesPersistence) IsMessageAlreadyCompleted(hash []byte) (bool, error)

func (RawMessagesPersistence) MarkAsConfirmed added in v0.73.5

func (db RawMessagesPersistence) MarkAsConfirmed(dataSyncID []byte, atLeastOne bool) (messageID types.HexBytes, err error)

MarkAsConfirmed marks all the messages with dataSyncID as confirmed and returns the messageIDs that can be considered confirmed. If atLeastOne is set it will return messageid if at least once of the messages sent has been confirmed

func (RawMessagesPersistence) RawMessageByID added in v0.73.5

func (db RawMessagesPersistence) RawMessageByID(id string) (*RawMessage, error)

func (RawMessagesPersistence) RawMessagesIDsByType added in v0.73.5

func (*RawMessagesPersistence) RemoveMessageSegmentsCompletedOlderThan added in v0.171.21

func (db *RawMessagesPersistence) RemoveMessageSegmentsCompletedOlderThan(timestamp int64) error

func (*RawMessagesPersistence) RemoveMessageSegmentsOlderThan added in v0.171.21

func (db *RawMessagesPersistence) RemoveMessageSegmentsOlderThan(timestamp int64) error

func (RawMessagesPersistence) SaveHashRatchetMessage added in v0.111.7

func (db RawMessagesPersistence) SaveHashRatchetMessage(groupID []byte, keyID []byte, m *types.Message) error

func (*RawMessagesPersistence) SaveMessageSegment added in v0.171.21

func (db *RawMessagesPersistence) SaveMessageSegment(segment *SegmentMessage, sigPubKey *ecdsa.PublicKey, timestamp int64) error

func (RawMessagesPersistence) SaveRawMessage added in v0.73.5

func (db RawMessagesPersistence) SaveRawMessage(message *RawMessage) error

func (RawMessagesPersistence) UpdateRawMessageLastSent added in v0.180.30

func (db RawMessagesPersistence) UpdateRawMessageLastSent(id string, lastSent uint64) error

func (RawMessagesPersistence) UpdateRawMessageSent added in v0.179.12

func (db RawMessagesPersistence) UpdateRawMessageSent(id string, sent bool) error

type ResendMethod added in v0.179.12

type ResendMethod uint8

ResendMethod defines how to resend a raw message

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
)

type ResendType added in v0.179.12

type ResendType uint8

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.

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
)

type SegmentMessage added in v0.179.5

type SegmentMessage struct {
	*protobuf.SegmentMessage
}

func (*SegmentMessage) IsParityMessage added in v0.179.5

func (s *SegmentMessage) IsParityMessage() bool

func (*SegmentMessage) IsValid added in v0.179.5

func (s *SegmentMessage) IsValid() bool

type SentMessage

type SentMessage struct {
	PublicKey  *ecdsa.PublicKey
	Spec       *encryption.ProtocolMessageSpec
	MessageIDs [][]byte
}

SentMessage reprent a message that has been passed to the transport layer

type SimplifiedTextVisitor added in v0.74.2

type SimplifiedTextVisitor struct {
	// contains filtered or unexported fields
}

implement interface of https://github.com/status-im/markdown/blob/b9fe921681227b1dace4b56364e15edb3b698308/ast/node.go#L701

func (*SimplifiedTextVisitor) Visit added in v0.74.2

func (v *SimplifiedTextVisitor) Visit(node ast.Node, entering bool) ast.WalkStatus

type StatusCommunityChannelLinkPreview added in v0.170.0

type StatusCommunityChannelLinkPreview struct {
	ChannelUUID string                      `json:"channelUuid"`
	Emoji       string                      `json:"emoji"`
	DisplayName string                      `json:"displayName"`
	Description string                      `json:"description"`
	Color       string                      `json:"color"`
	Community   *StatusCommunityLinkPreview `json:"community"`
}

type StatusCommunityLinkPreview added in v0.170.0

type StatusCommunityLinkPreview struct {
	CommunityID  string               `json:"communityId"`
	DisplayName  string               `json:"displayName"`
	Description  string               `json:"description"`
	MembersCount uint32               `json:"membersCount"`
	Color        string               `json:"color"`
	Icon         LinkPreviewThumbnail `json:"icon,omitempty"`
	Banner       LinkPreviewThumbnail `json:"banner,omitempty"`
}

type StatusContactLinkPreview added in v0.170.0

type StatusContactLinkPreview struct {
	// PublicKey is: "0x" + hex-encoded decompressed public key.
	// We keep it a string here for correct json marshalling.
	PublicKey   string               `json:"publicKey"`
	DisplayName string               `json:"displayName"`
	Description string               `json:"description"`
	Icon        LinkPreviewThumbnail `json:"icon,omitempty"`
}

type StatusLinkPreview added in v0.170.0

type StatusLinkPreview struct {
	URL       string                             `json:"url,omitempty"`
	Contact   *StatusContactLinkPreview          `json:"contact,omitempty"`
	Community *StatusCommunityLinkPreview        `json:"community,omitempty"`
	Channel   *StatusCommunityChannelLinkPreview `json:"channel,omitempty"`
}

type TimeSource added in v0.67.0

type TimeSource interface {
	GetCurrentTime() uint64
}

TimeSource provides a unified way of getting the current time. The intention is to always use a synchronized time source between all components of the protocol.

This is required by Whisper and Waku protocols which rely on a fact that all peers have a synchronized time source.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL