Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateAlias(id string) (string, error)
- func Identicon(id string) (string, error)
- func ValidateMembershipUpdateMessage(message *protocol.MembershipUpdateMessage, timeNowMs uint64) error
- func ValidateReceivedAcceptRequestAddressForTransaction(message *protobuf.AcceptRequestAddressForTransaction, whisperTimestamp uint64) error
- func ValidateReceivedChatMessage(message *protobuf.ChatMessage, whisperTimestamp uint64) error
- func ValidateReceivedDeclineRequestAddressForTransaction(message *protobuf.DeclineRequestAddressForTransaction, whisperTimestamp uint64) error
- func ValidateReceivedDeclineRequestTransaction(message *protobuf.DeclineRequestTransaction, whisperTimestamp uint64) error
- func ValidateReceivedEmojiReaction(emoji *protobuf.EmojiReaction, whisperTimestamp uint64) error
- func ValidateReceivedPairInstallation(message *protobuf.PairInstallation, whisperTimestamp uint64) error
- func ValidateReceivedRequestAddressForTransaction(message *protobuf.RequestAddressForTransaction, whisperTimestamp uint64) error
- func ValidateReceivedRequestTransaction(message *protobuf.RequestTransaction, whisperTimestamp uint64) error
- func ValidateReceivedSendTransaction(message *protobuf.SendTransaction, whisperTimestamp uint64) error
- func WithDatasync() func(c *config) error
- func WithPushNotifications() func(c *config) error
- type Chat
- func (c *Chat) HasMember(memberID string) bool
- func (c *Chat) MembersAsPublicKeys() ([]*ecdsa.PublicKey, error)
- func (c *Chat) NextClockAndTimestamp(timesource TimeSource) (uint64, uint64)
- func (c *Chat) OneToOne() bool
- func (c *Chat) Public() bool
- func (c *Chat) PublicKey() (*ecdsa.PublicKey, error)
- func (c *Chat) UpdateFromMessage(message *Message, timesource TimeSource) error
- func (c *Chat) Validate() error
- type ChatMember
- type ChatMembershipUpdate
- type ChatType
- type CommandParameters
- type CommandState
- type Contact
- type ContactDeviceInfo
- type CurrentMessageState
- type EmojiReaction
- type EthClient
- type Message
- func (m *Message) GetProtobuf() proto.Message
- func (m Message) GetSigPubKey() *ecdsa.PublicKey
- func (m *Message) MarshalJSON() ([]byte, error)
- func (m *Message) PrepareContent() error
- func (m *Message) SetMessageType(messageType protobuf.MessageType)
- func (m *Message) UnmarshalJSON(data []byte) error
- type MessageHandler
- func (m *MessageHandler) HandleAcceptRequestAddressForTransaction(messageState *ReceivedMessageState, ...) error
- func (m *MessageHandler) HandleChatMessage(state *ReceivedMessageState) error
- func (m *MessageHandler) HandleContactUpdate(state *ReceivedMessageState, message protobuf.ContactUpdate) error
- func (m *MessageHandler) HandleDeclineRequestAddressForTransaction(messageState *ReceivedMessageState, ...) error
- func (m *MessageHandler) HandleDeclineRequestTransaction(messageState *ReceivedMessageState, command protobuf.DeclineRequestTransaction) error
- func (m *MessageHandler) HandleEmojiReaction(state *ReceivedMessageState, pbEmojiR protobuf.EmojiReaction) error
- func (m *MessageHandler) HandleMembershipUpdate(messageState *ReceivedMessageState, chat *Chat, ...) error
- func (m *MessageHandler) HandlePairInstallation(state *ReceivedMessageState, message protobuf.PairInstallation) error
- func (m *MessageHandler) HandleRequestAddressForTransaction(messageState *ReceivedMessageState, ...) error
- func (m *MessageHandler) HandleRequestTransaction(messageState *ReceivedMessageState, command protobuf.RequestTransaction) error
- func (m *MessageHandler) HandleSendTransaction(messageState *ReceivedMessageState, command protobuf.SendTransaction) error
- func (m *MessageHandler) HandleSyncInstallationContact(state *ReceivedMessageState, message protobuf.SyncInstallationContact) error
- func (m *MessageHandler) HandleSyncInstallationPublicChat(state *ReceivedMessageState, message protobuf.SyncInstallationPublicChat) error
- type Messenger
- func (m *Messenger) AcceptRequestAddressForTransaction(ctx context.Context, messageID, address string) (*MessengerResponse, error)
- func (m *Messenger) AcceptRequestTransaction(ctx context.Context, transactionHash, messageID string, signature []byte) (*MessengerResponse, error)
- func (m *Messenger) AddAdminsToGroupChat(ctx context.Context, chatID string, members []string) (*MessengerResponse, error)
- func (m *Messenger) AddMailserver(enode string) error
- func (m *Messenger) AddMembersToGroupChat(ctx context.Context, chatID string, members []string) (*MessengerResponse, error)
- func (m *Messenger) AddPushNotificationsServer(ctx context.Context, publicKey *ecdsa.PublicKey) error
- func (m *Messenger) BlockContact(contact *Contact) ([]*Chat, error)
- func (m *Messenger) ChangeGroupChatName(ctx context.Context, chatID string, name string) (*MessengerResponse, error)
- func (m *Messenger) Chats() []*Chat
- func (m *Messenger) ConfirmJoiningGroup(ctx context.Context, chatID string) (*MessengerResponse, error)
- func (m *Messenger) ConfirmMessagesProcessed(messageIDs [][]byte) error
- func (m *Messenger) Contacts() []*Contact
- func (m *Messenger) CreateGroupChatWithMembers(ctx context.Context, name string, members []string) (*MessengerResponse, error)
- func (m *Messenger) DeclineRequestAddressForTransaction(ctx context.Context, messageID string) (*MessengerResponse, error)
- func (m *Messenger) DeclineRequestTransaction(ctx context.Context, messageID string) (*MessengerResponse, error)
- func (m *Messenger) DeleteChat(chatID string) error
- func (m *Messenger) DeleteMessage(id string) error
- func (m *Messenger) DeleteMessagesByChatID(id string) error
- func (m *Messenger) DisableInstallation(id string) error
- func (m *Messenger) DisablePushNotificationsFromContactsOnly() error
- func (m *Messenger) DisableSendingPushNotifications() error
- func (m *Messenger) EmojiReactionsByChatID(chatID string, cursor string, limit int) ([]*EmojiReaction, error)
- func (m *Messenger) EnableInstallation(id string) error
- func (m *Messenger) EnablePushNotificationsFromContactsOnly() error
- func (m *Messenger) EnableSendingPushNotifications() error
- func (m *Messenger) GetContactByID(pubKey string) *Contact
- func (m *Messenger) GetPushNotificationServers() ([]*pushnotificationclient.PushNotificationServer, error)
- func (m *Messenger) Init() error
- func (m *Messenger) Installations() []*multidevice.Installation
- func (m *Messenger) Join(chat Chat) error
- func (m *Messenger) Leave(chat Chat) error
- func (m *Messenger) LeaveGroupChat(ctx context.Context, chatID string, remove bool) (*MessengerResponse, error)
- func (m *Messenger) LoadFilters(filters []*transport.Filter) ([]*transport.Filter, error)
- func (m *Messenger) Mailservers() ([]string, error)
- func (m *Messenger) MarkAllRead(chatID string) error
- func (m *Messenger) MarkMessagesSeen(chatID string, ids []string) (uint64, error)
- func (m *Messenger) MessageByChatID(chatID, cursor string, limit int) ([]*Message, string, error)
- func (m *Messenger) MessageByID(id string) (*Message, error)
- func (m *Messenger) MessagesExist(ids []string) (map[string]bool, error)
- func (m *Messenger) MuteChat(chatID string) error
- func (m *Messenger) ReSendChatMessage(ctx context.Context, messageID string) error
- func (m *Messenger) RegisterForPushNotifications(ctx context.Context, deviceToken string) error
- func (m *Messenger) RegisteredForPushNotifications() (bool, error)
- func (m *Messenger) RemoveFilters(filters []*transport.Filter) error
- func (m *Messenger) RemoveMailserver(id string) error
- func (m *Messenger) RemoveMemberFromGroupChat(ctx context.Context, chatID string, member string) (*MessengerResponse, error)
- func (m *Messenger) RemovePushNotificationServer(ctx context.Context, publicKey *ecdsa.PublicKey) error
- func (m *Messenger) RequestAddressForTransaction(ctx context.Context, chatID, from, value, contract string) (*MessengerResponse, error)
- func (m *Messenger) RequestHistoricMessages(ctx context.Context, from, to uint32, cursor []byte) ([]byte, error)
- func (m *Messenger) RequestTransaction(ctx context.Context, chatID, value, contract, address string) (*MessengerResponse, error)
- func (m *Messenger) RetrieveAll() (*MessengerResponse, error)
- func (m *Messenger) SaveChat(chat *Chat) error
- func (m *Messenger) SaveContact(contact *Contact) error
- func (m *Messenger) SaveMessages(messages []*Message) error
- func (m *Messenger) SelectMailserver(id string) error
- func (m *Messenger) SendChatMessage(ctx context.Context, message *Message) (*MessengerResponse, error)
- func (m *Messenger) SendContactUpdate(ctx context.Context, chatID, ensName, profileImage string) (*MessengerResponse, error)
- func (m *Messenger) SendContactUpdates(ctx context.Context, ensName, profileImage string) error
- func (m *Messenger) SendEmojiReaction(ctx context.Context, chatID, messageID string, ...) (*MessengerResponse, error)
- func (m *Messenger) SendEmojiReactionRetraction(ctx context.Context, emojiReactionID string) (*MessengerResponse, error)
- func (m *Messenger) SendPairInstallation(ctx context.Context) (*MessengerResponse, error)
- func (m *Messenger) SendTransaction(ctx context.Context, chatID, value, contract, transactionHash string, ...) (*MessengerResponse, error)
- func (m *Messenger) SetInstallationMetadata(id string, data *multidevice.InstallationMetadata) error
- func (m *Messenger) SetMailserver(peer []byte)
- func (m *Messenger) Shutdown() (err error)
- func (m *Messenger) SignMessage(message string) ([]byte, error)
- func (m *Messenger) Start() error
- func (m *Messenger) StartPushNotificationsServer() error
- func (m *Messenger) StopPushNotificationsServer() error
- func (m *Messenger) SyncDevices(ctx context.Context, ensName, photoPath string) error
- func (m *Messenger) Timesource() TimeSource
- func (m *Messenger) UnmuteChat(chatID string) error
- func (m *Messenger) UnregisterFromPushNotifications(ctx context.Context) error
- func (m *Messenger) UpdateMessageOutgoingStatus(id, newOutgoingStatus string) error
- func (m *Messenger) ValidateTransactions(ctx context.Context, addresses []types.Address) (*MessengerResponse, error)
- func (m *Messenger) VerifyENSNames(ctx context.Context, rpcEndpoint, contractAddress string) (*MessengerResponse, error)
- type MessengerResponse
- type Option
- func WithCustomLogger(logger *zap.Logger) Option
- func WithDatabase(db *sql.DB) Option
- func WithDatabaseConfig(dbPath, dbKey string) Option
- func WithEnvelopesMonitorConfig(emc *transport.EnvelopesMonitorConfig) Option
- func WithMessagesPersistenceEnabled() Option
- func WithOnNegotiatedFilters(h func([]*transport.Filter)) Option
- func WithPushNotificationClientConfig(pushNotificationClientConfig *pushnotificationclient.Config) Option
- func WithPushNotificationServerConfig(pushNotificationServerConfig *pushnotificationserver.Config) Option
- func WithSystemMessagesTranslations(t map[protobuf.MembershipUpdateEvent_EventType]string) Option
- func WithVerifyTransactionClient(client EthClient) Option
- type QuotedMessage
- type RawResponse
- type ReceivedMessageState
- type TimeSource
- type TransactionToValidate
- type TransactionValidator
- type VerifyTransactionResponse
Constants ¶
const ( OutgoingStatusSending = "sending" OutgoingStatusSent = "sent" )
const ENSBackoffTimeSec uint64 = 30
ENSBackoffTimeSec is the step of the exponential backoff we retry roughly for 17 hours after receiving the message 2^11 * 30
const PubKeyStringLength = 132
Variables ¶
var ( ErrChatIDEmpty = errors.New("chat ID is empty") ErrChatNotFound = errors.New("can't find chat") ErrNotImplemented = errors.New("not implemented") )
var ( // ErrMsgAlreadyExist returned if msg already exist. ErrMsgAlreadyExist = errors.New("message with given ID already exist") )
Functions ¶
func GenerateAlias ¶
GenerateAlias name returns the generated name given a public key hex encoded prefixed with 0x
func ValidateReceivedAcceptRequestAddressForTransaction ¶
func ValidateReceivedAcceptRequestAddressForTransaction(message *protobuf.AcceptRequestAddressForTransaction, whisperTimestamp uint64) error
func ValidateReceivedChatMessage ¶
func ValidateReceivedChatMessage(message *protobuf.ChatMessage, whisperTimestamp uint64) error
func ValidateReceivedDeclineRequestAddressForTransaction ¶
func ValidateReceivedDeclineRequestAddressForTransaction(message *protobuf.DeclineRequestAddressForTransaction, whisperTimestamp uint64) error
func ValidateReceivedDeclineRequestTransaction ¶
func ValidateReceivedDeclineRequestTransaction(message *protobuf.DeclineRequestTransaction, whisperTimestamp uint64) error
func ValidateReceivedEmojiReaction ¶ added in v0.56.4
func ValidateReceivedEmojiReaction(emoji *protobuf.EmojiReaction, whisperTimestamp uint64) error
func ValidateReceivedPairInstallation ¶
func ValidateReceivedPairInstallation(message *protobuf.PairInstallation, whisperTimestamp uint64) error
func ValidateReceivedRequestAddressForTransaction ¶
func ValidateReceivedRequestAddressForTransaction(message *protobuf.RequestAddressForTransaction, whisperTimestamp uint64) error
func ValidateReceivedRequestTransaction ¶
func ValidateReceivedRequestTransaction(message *protobuf.RequestTransaction, whisperTimestamp uint64) error
func ValidateReceivedSendTransaction ¶
func ValidateReceivedSendTransaction(message *protobuf.SendTransaction, whisperTimestamp uint64) error
func WithDatasync ¶
func WithDatasync() func(c *config) error
func WithPushNotifications ¶ added in v0.56.1
func WithPushNotifications() func(c *config) error
Types ¶
type Chat ¶
type Chat struct { // ID is the id of the chat, for public chats it is the name e.g. status, for one-to-one // is the hex encoded public key and for group chats is a random uuid appended with // the hex encoded pk of the creator of the chat ID string `json:"id"` Name string `json:"name"` Color string `json:"color"` // Active indicates whether the chat has been soft deleted Active bool `json:"active"` ChatType ChatType `json:"chatType"` // Timestamp indicates the last time this chat has received/sent a message Timestamp int64 `json:"timestamp"` // LastClockValue indicates the last clock value to be used when sending messages LastClockValue uint64 `json:"lastClockValue"` // DeletedAtClockValue indicates the clock value at time of deletion, messages // with lower clock value of this should be discarded DeletedAtClockValue uint64 `json:"deletedAtClockValue"` // Denormalized fields UnviewedMessagesCount uint `json:"unviewedMessagesCount"` LastMessage *Message `json:"lastMessage"` // Group chat fields // Members are the members who have been invited to the group chat Members []ChatMember `json:"members"` // MembershipUpdates is all the membership events in the chat MembershipUpdates []v1protocol.MembershipUpdateEvent `json:"membershipUpdateEvents"` // Generated username name of the chat for one-to-ones Alias string `json:"alias,omitempty"` // Identicon generated from public key Identicon string `json:"identicon"` // Muted is used to check whether we want to receive // push notifications for this chat Muted bool `json:"muted,omitempty"` }
func CreateGroupChat ¶
func CreateGroupChat(timesource TimeSource) Chat
func CreateOneToOneChat ¶
func CreateOneToOneChat(name string, publicKey *ecdsa.PublicKey, timesource TimeSource) Chat
func CreatePublicChat ¶
func CreatePublicChat(name string, timesource TimeSource) Chat
func OneToOneFromPublicKey ¶
func OneToOneFromPublicKey(pk *ecdsa.PublicKey, timesource TimeSource) *Chat
func (*Chat) NextClockAndTimestamp ¶
func (c *Chat) NextClockAndTimestamp(timesource TimeSource) (uint64, uint64)
NextClockAndTimestamp returns the next clock value and the current timestamp
func (*Chat) UpdateFromMessage ¶
func (c *Chat) UpdateFromMessage(message *Message, timesource TimeSource) error
type ChatMember ¶
type ChatMember struct { // ID is the hex encoded public key of the member ID string `json:"id"` // Admin indicates if the member is an admin of the group chat Admin bool `json:"admin"` // Joined indicates if the member has joined the group chat Joined bool `json:"joined"` }
ChatMember represents a member who participates in a group chat
type ChatMembershipUpdate ¶
type ChatMembershipUpdate struct { // Unique identifier for the event ID string `json:"id"` // Type indicates the kind of event Type protobuf.MembershipUpdateEvent_EventType `json:"type"` // Name represents the name in the event of changing name events Name string `json:"name,omitempty"` // Clock value of the event ClockValue uint64 `json:"clockValue"` // Signature of the event Signature string `json:"signature"` // Hex encoded public key of the creator of the event From string `json:"from"` // Target of the event for single-target events Member string `json:"member,omitempty"` // Target of the event for multi-target events Members []string `json:"members,omitempty"` }
ChatMembershipUpdate represent an event on membership of the chat
type CommandParameters ¶
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 ¶
func (c *CommandParameters) IsTokenTransfer() bool
type CommandState ¶
type CommandState int
const ( CommandStateRequestAddressForTransaction CommandState = iota + 1 CommandStateRequestAddressForTransactionDeclined CommandStateRequestAddressForTransactionAccepted CommandStateRequestTransaction CommandStateRequestTransactionDeclined CommandStateTransactionPending CommandStateTransactionSent )
type Contact ¶
type Contact struct { // ID of the contact. It's a hex-encoded public key (prefixed with 0x). ID string `json:"id"` // Ethereum address of the contact Address string `json:"address,omitempty"` // ENS name of contact Name string `json:"name,omitempty"` // EnsVerified whether we verified the name of the contact ENSVerified bool `json:"ensVerified"` // EnsVerifiedAt the time we last verified the name ENSVerifiedAt uint64 `json:"ensVerifiedAt"` // LastENSClockValue is the last clock value of when we // received an ENS name for the user LastENSClockValue uint64 `json:"lastENSClockValue"` // ENSVerificationRetries is how many times we retried the ENS ENSVerificationRetries uint64 `json:"ensVerificationRetries"` // Generated username name of the contact Alias string `json:"alias,omitempty"` // Identicon generated from public key Identicon string `json:"identicon"` // Photo is the base64 encoded photo Photo string `json:"photoPath,omitempty"` // LastUpdated is the last time we received an update from the contact // updates should be discarded if last updated is less than the one stored LastUpdated uint64 `json:"lastUpdated"` // SystemTags contains information about whether we blocked/added/have been // added. SystemTags []string `json:"systemTags"` DeviceInfo []ContactDeviceInfo `json:"deviceInfo"` TributeToTalk string `json:"tributeToTalk,omitempty"` }
Contact has information about a "Contact". A contact is not necessarily one that we added or added us, that's based on SystemTags.
func (Contact) HasBeenAdded ¶
func (Contact) HasCustomFields ¶ added in v0.52.3
HasCustomFields returns whether the the contact has any field that is valuable to the client other than the computed name/image
func (*Contact) ResetENSVerification ¶
type ContactDeviceInfo ¶
type ContactDeviceInfo struct { // The installation id of the device InstallationID string `json:"id"` // Timestamp represents the last time we received this info Timestamp int64 `json:"timestamp"` // FCMToken is to be used for push notifications FCMToken string `json:"fcmToken"` }
ContactDeviceInfo is a struct containing information about a particular device owned by a contact
type CurrentMessageState ¶
type CurrentMessageState struct { // Message is the protobuf message received Message protobuf.ChatMessage // MessageID is the ID of the message MessageID string // WhisperTimestamp is the whisper timestamp of the message WhisperTimestamp uint64 // Contact is the contact associated with the author of the message Contact *Contact // PublicKey is the public key of the author of the message PublicKey *ecdsa.PublicKey }
type EmojiReaction ¶ added in v0.56.4
type EmojiReaction struct { protobuf.EmojiReaction // From is a public key of the author of the emoji reaction. From string `json:"from,omitempty"` // SigPubKey is the ecdsa encoded public key of the emoji reaction author SigPubKey *ecdsa.PublicKey `json:"-"` // LocalChatID is the chatID of the local chat (one-to-one are not symmetric) LocalChatID string `json:"localChatId"` }
EmojiReaction represents an emoji reaction from a user in the application layer, used for persistence, querying and signaling
func (EmojiReaction) GetProtobuf ¶ added in v0.56.4
func (e EmojiReaction) GetProtobuf() proto.Message
GetProtoBuf returns the struct's embedded protobuf struct this function is required to implement the ChatEntity interface
func (EmojiReaction) GetSigPubKey ¶ added in v0.56.4
func (e EmojiReaction) GetSigPubKey() *ecdsa.PublicKey
GetSigPubKey returns an ecdsa encoded public key this function is required to implement the ChatEntity interface
func (EmojiReaction) ID ¶ added in v0.56.4
func (e EmojiReaction) ID() string
ID is the Keccak256() contatenation of From-MessageID-EmojiType
func (EmojiReaction) MarshalJSON ¶ added in v0.56.4
func (e EmojiReaction) MarshalJSON() ([]byte, error)
func (*EmojiReaction) SetMessageType ¶ added in v0.56.4
func (e *EmojiReaction) SetMessageType(messageType protobuf.MessageType)
SetMessageType a setter for the MessageType field this function is required to implement the ChatEntity interface
type Message ¶
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 bool `json:"seen"` OutgoingStatus string `json:"outgoingStatus,omitempty"` QuotedMessage *QuotedMessage `json:"quotedMessage"` // CommandParameters is the parameters sent with the message CommandParameters *CommandParameters `json:"commandParameters"` // 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"` // 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"` // Replace indicates that this is a replacement of a message // that has been updated Replace string `json:"replace,omitempty"` SigPubKey *ecdsa.PublicKey `json:"-"` }
Message represents a message record in the database, more specifically in user_messages table.
func (*Message) GetProtobuf ¶ added in v0.56.4
GetProtoBuf returns the struct's embedded protobuf struct this function is required to implement the ChatEntity interface
func (Message) GetSigPubKey ¶ added in v0.56.4
GetSigPubKey returns an ecdsa encoded public key this function is required to implement the ChatEntity interface
func (*Message) MarshalJSON ¶
func (*Message) PrepareContent ¶
PrepareContent return the parsed content of the message, the line-count and whether is a right-to-left message
func (*Message) SetMessageType ¶ added in v0.56.4
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 ¶
type MessageHandler ¶
type MessageHandler struct {
// contains filtered or unexported fields
}
func (*MessageHandler) HandleAcceptRequestAddressForTransaction ¶
func (m *MessageHandler) HandleAcceptRequestAddressForTransaction(messageState *ReceivedMessageState, command protobuf.AcceptRequestAddressForTransaction) error
func (*MessageHandler) HandleChatMessage ¶
func (m *MessageHandler) HandleChatMessage(state *ReceivedMessageState) error
func (*MessageHandler) HandleContactUpdate ¶
func (m *MessageHandler) HandleContactUpdate(state *ReceivedMessageState, message protobuf.ContactUpdate) error
func (*MessageHandler) HandleDeclineRequestAddressForTransaction ¶
func (m *MessageHandler) HandleDeclineRequestAddressForTransaction(messageState *ReceivedMessageState, command protobuf.DeclineRequestAddressForTransaction) error
func (*MessageHandler) HandleDeclineRequestTransaction ¶
func (m *MessageHandler) HandleDeclineRequestTransaction(messageState *ReceivedMessageState, command protobuf.DeclineRequestTransaction) error
func (*MessageHandler) HandleEmojiReaction ¶ added in v0.56.4
func (m *MessageHandler) HandleEmojiReaction(state *ReceivedMessageState, pbEmojiR protobuf.EmojiReaction) error
func (*MessageHandler) HandleMembershipUpdate ¶
func (m *MessageHandler) HandleMembershipUpdate(messageState *ReceivedMessageState, chat *Chat, rawMembershipUpdate protobuf.MembershipUpdateMessage, translations map[protobuf.MembershipUpdateEvent_EventType]string) error
HandleMembershipUpdate updates a Chat instance according to the membership updates. It retrieves chat, if exists, and merges membership updates from the message. Finally, the Chat is updated with the new group events.
func (*MessageHandler) HandlePairInstallation ¶
func (m *MessageHandler) HandlePairInstallation(state *ReceivedMessageState, message protobuf.PairInstallation) error
func (*MessageHandler) HandleRequestAddressForTransaction ¶
func (m *MessageHandler) HandleRequestAddressForTransaction(messageState *ReceivedMessageState, command protobuf.RequestAddressForTransaction) error
func (*MessageHandler) HandleRequestTransaction ¶
func (m *MessageHandler) HandleRequestTransaction(messageState *ReceivedMessageState, command protobuf.RequestTransaction) error
func (*MessageHandler) HandleSendTransaction ¶
func (m *MessageHandler) HandleSendTransaction(messageState *ReceivedMessageState, command protobuf.SendTransaction) error
func (*MessageHandler) HandleSyncInstallationContact ¶
func (m *MessageHandler) HandleSyncInstallationContact(state *ReceivedMessageState, message protobuf.SyncInstallationContact) error
func (*MessageHandler) HandleSyncInstallationPublicChat ¶
func (m *MessageHandler) HandleSyncInstallationPublicChat(state *ReceivedMessageState, message protobuf.SyncInstallationPublicChat) error
type Messenger ¶
type Messenger struct {
// contains filtered or unexported fields
}
Messenger is a entity managing chats and messages. It acts as a bridge between the application and encryption layers. It needs to expose an interface to manage installations because installations are managed by the user. Similarly, it needs to expose an interface to manage mailservers because they can also be managed by the user.
func NewMessenger ¶
func (*Messenger) AcceptRequestAddressForTransaction ¶
func (*Messenger) AcceptRequestTransaction ¶
func (*Messenger) AddAdminsToGroupChat ¶
func (*Messenger) AddMailserver ¶
NOT IMPLEMENTED
func (*Messenger) AddMembersToGroupChat ¶
func (*Messenger) AddPushNotificationsServer ¶ added in v0.56.1
func (m *Messenger) AddPushNotificationsServer(ctx context.Context, publicKey *ecdsa.PublicKey) error
AddPushNotificationsServer adds a push notification server
func (*Messenger) BlockContact ¶
func (*Messenger) ChangeGroupChatName ¶ added in v0.52.1
func (*Messenger) ConfirmJoiningGroup ¶
func (*Messenger) ConfirmMessagesProcessed ¶
func (*Messenger) CreateGroupChatWithMembers ¶
func (*Messenger) DeclineRequestAddressForTransaction ¶
func (*Messenger) DeclineRequestTransaction ¶
func (*Messenger) DeleteChat ¶
func (*Messenger) DeleteMessage ¶
func (*Messenger) DeleteMessagesByChatID ¶
func (*Messenger) DisableInstallation ¶
func (*Messenger) DisablePushNotificationsFromContactsOnly ¶ added in v0.56.1
DisablePushNotificationsFromContactsOnly is used to indicate that we want to received push notifications from anyone
func (*Messenger) DisableSendingPushNotifications ¶ added in v0.56.1
DisableSendingPushNotifications signals the client not to send any push notification
func (*Messenger) EmojiReactionsByChatID ¶ added in v0.56.4
func (*Messenger) EnableInstallation ¶
func (*Messenger) EnablePushNotificationsFromContactsOnly ¶ added in v0.56.1
EnablePushNotificationsFromContactsOnly is used to indicate that we want to received push notifications only from contacts
func (*Messenger) EnableSendingPushNotifications ¶ added in v0.56.1
EnableSendingPushNotifications signals the client to send push notifications
func (*Messenger) GetContactByID ¶ added in v0.44.2
GetContactByID assumes pubKey includes 0x prefix
func (*Messenger) GetPushNotificationServers ¶ added in v0.56.1
func (m *Messenger) GetPushNotificationServers() ([]*pushnotificationclient.PushNotificationServer, error)
GetPushNotificationServers returns the servers used for push notifications
func (*Messenger) Init ¶
Init analyzes chats and contacts in order to setup filters which are responsible for retrieving messages.
func (*Messenger) Installations ¶
func (m *Messenger) Installations() []*multidevice.Installation
func (*Messenger) Leave ¶
This is not accurate, it should not leave transport on removal of chat/group only once there is no more: Group chat with that member, one-to-one chat, contact added by us
func (*Messenger) LeaveGroupChat ¶
func (*Messenger) LoadFilters ¶
func (*Messenger) MarkAllRead ¶ added in v0.47.0
func (*Messenger) MarkMessagesSeen ¶
MarkMessagesSeen marks messages with `ids` as seen in the chat `chatID`. It returns the number of affected messages or error. If there is an error, the number of affected messages is always zero.
func (*Messenger) MessageByChatID ¶
func (*Messenger) MessagesExist ¶
func (*Messenger) MuteChat ¶ added in v0.56.1
MuteChat signals to the messenger that we don't want to be notified on new messages from this chat
func (*Messenger) ReSendChatMessage ¶
ReSendChatMessage pulls a message from the database and sends it again
func (*Messenger) RegisterForPushNotifications ¶ added in v0.56.1
RegisterForPushNotification register deviceToken with any push notification server enabled
func (*Messenger) RegisteredForPushNotifications ¶ added in v0.56.1
RegisteredForPushNotifications returns whether we successfully registered with all the servers
func (*Messenger) RemoveFilters ¶
func (*Messenger) RemoveMailserver ¶
NOT IMPLEMENTED
func (*Messenger) RemoveMemberFromGroupChat ¶
func (*Messenger) RemovePushNotificationServer ¶ added in v0.56.1
func (m *Messenger) RemovePushNotificationServer(ctx context.Context, publicKey *ecdsa.PublicKey) error
RemovePushNotificationServer removes a push notification server
func (*Messenger) RequestAddressForTransaction ¶
func (*Messenger) RequestHistoricMessages ¶
func (*Messenger) RequestTransaction ¶
func (*Messenger) RetrieveAll ¶
func (m *Messenger) RetrieveAll() (*MessengerResponse, error)
RetrieveAll retrieves messages from all filters, processes them and returns a MessengerResponse to the client
func (*Messenger) SaveContact ¶
func (*Messenger) SaveMessages ¶
func (*Messenger) SelectMailserver ¶
NOT IMPLEMENTED
func (*Messenger) SendChatMessage ¶
func (m *Messenger) SendChatMessage(ctx context.Context, message *Message) (*MessengerResponse, error)
SendChatMessage takes a minimal message and sends it based on the corresponding chat
func (*Messenger) SendContactUpdate ¶
func (m *Messenger) SendContactUpdate(ctx context.Context, chatID, ensName, profileImage string) (*MessengerResponse, error)
SendContactUpdate sends a contact update to a user and adds the user to contacts
func (*Messenger) SendContactUpdates ¶
Send contact updates to all contacts added by us
func (*Messenger) SendEmojiReaction ¶ added in v0.56.4
func (m *Messenger) SendEmojiReaction(ctx context.Context, chatID, messageID string, emojiID protobuf.EmojiReaction_Type) (*MessengerResponse, error)
func (*Messenger) SendEmojiReactionRetraction ¶ added in v0.56.4
func (*Messenger) SendPairInstallation ¶
func (m *Messenger) SendPairInstallation(ctx context.Context) (*MessengerResponse, error)
SendPairInstallation sends a pair installation message
func (*Messenger) SendTransaction ¶
func (*Messenger) SetInstallationMetadata ¶
func (m *Messenger) SetInstallationMetadata(id string, data *multidevice.InstallationMetadata) error
func (*Messenger) SetMailserver ¶ added in v0.56.1
SetMailserver sets the currently used mailserver
func (*Messenger) SignMessage ¶ added in v0.56.6
func (*Messenger) StartPushNotificationsServer ¶ added in v0.56.1
StartPushNotificationsServer initialize and start a push notification server, using the current messenger identity key
func (*Messenger) StopPushNotificationsServer ¶ added in v0.56.1
StopPushNotificationServer stops the push notification server if running
func (*Messenger) SyncDevices ¶
SyncDevices sends all public chats and contacts to paired devices
func (*Messenger) Timesource ¶
func (m *Messenger) Timesource() TimeSource
func (*Messenger) UnmuteChat ¶ added in v0.56.1
UnmuteChat signals to the messenger that we want to be notified on new messages from this chat
func (*Messenger) UnregisterFromPushNotifications ¶ added in v0.56.1
UnregisterFromPushNotifications unregister from any server
func (*Messenger) UpdateMessageOutgoingStatus ¶
func (*Messenger) ValidateTransactions ¶
func (*Messenger) VerifyENSNames ¶
func (m *Messenger) VerifyENSNames(ctx context.Context, rpcEndpoint, contractAddress string) (*MessengerResponse, error)
VerifyENSNames verifies that a registered ENS name matches the expected public key
type MessengerResponse ¶
type MessengerResponse struct { Chats []*Chat `json:"chats,omitempty"` Messages []*Message `json:"messages,omitempty"` Contacts []*Contact `json:"contacts,omitempty"` Installations []*multidevice.Installation `json:"installations,omitempty"` EmojiReactions []*EmojiReaction `json:"emojiReactions,omitempty"` }
func (*MessengerResponse) IsEmpty ¶
func (m *MessengerResponse) IsEmpty() bool
type Option ¶
type Option func(*config) error
func WithCustomLogger ¶
func WithDatabase ¶
func WithDatabaseConfig ¶
func WithEnvelopesMonitorConfig ¶
func WithEnvelopesMonitorConfig(emc *transport.EnvelopesMonitorConfig) Option
func WithMessagesPersistenceEnabled ¶
func WithMessagesPersistenceEnabled() Option
func WithOnNegotiatedFilters ¶
func WithPushNotificationClientConfig ¶ added in v0.56.1
func WithPushNotificationClientConfig(pushNotificationClientConfig *pushnotificationclient.Config) Option
func WithPushNotificationServerConfig ¶ added in v0.56.1
func WithPushNotificationServerConfig(pushNotificationServerConfig *pushnotificationserver.Config) Option
func WithSystemMessagesTranslations ¶
func WithSystemMessagesTranslations(t map[protobuf.MembershipUpdateEvent_EventType]string) Option
WithSystemMessagesTranslations is required for Group Chats which are currently disabled. nolint: unused
type QuotedMessage ¶
type QuotedMessage struct { // From is a public key of the author of the message. From string `json:"from"` Text string `json:"text"` // Base64Image is the converted base64 image Base64Image string `json:"image,omitempty"` // Base64Audio is the converted base64 audio Base64Audio string `json:"audio,omitempty"` // AudioDurationMs is the audio duration in milliseconds AudioDurationMs uint64 `json:"audioDurationMs,omitempty"` }
QuotedMessage contains the original text of the message replied to
type RawResponse ¶
type RawResponse struct { Filter *transport.Filter `json:"filter"` Messages []*v1protocol.StatusMessage `json:"messages"` }
type ReceivedMessageState ¶
type ReceivedMessageState struct { // State on the message being processed CurrentMessageState *CurrentMessageState // AllChats in memory AllChats map[string]*Chat // List of chats modified ModifiedChats map[string]bool // All contacts in memory AllContacts map[string]*Contact // List of contacts modified ModifiedContacts map[string]bool // All installations in memory AllInstallations map[string]*multidevice.Installation // List of installations modified ModifiedInstallations map[string]bool // Map of existing messages ExistingMessagesMap map[string]bool // EmojiReactions is a list of emoji reactions for the current batch // indexed by from-message-id-emoji-type EmojiReactions map[string]*EmojiReaction // Response to the client Response *MessengerResponse // Timesource is a time source for clock values/timestamps. Timesource TimeSource }
type TimeSource ¶
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.
type TransactionToValidate ¶
type TransactionToValidate struct { TransactionHash string CommandID string MessageID string RetryCount int // First seen indicates the whisper timestamp of the first time we seen this FirstSeen uint64 // Validate indicates whether we should be validating this transaction Validate bool Signature []byte From *ecdsa.PublicKey }
type TransactionValidator ¶
type TransactionValidator struct {
// contains filtered or unexported fields
}
func NewTransactionValidator ¶
func (*TransactionValidator) ValidateTransaction ¶
func (t *TransactionValidator) ValidateTransaction(ctx context.Context, parameters *CommandParameters, from *ecdsa.PublicKey) (*VerifyTransactionResponse, error)
func (*TransactionValidator) ValidateTransactions ¶
func (t *TransactionValidator) ValidateTransactions(ctx context.Context) ([]*VerifyTransactionResponse, error)
type VerifyTransactionResponse ¶
type VerifyTransactionResponse struct { Pending bool // AccordingToSpec means that the transaction is valid, // the user should be notified, but is not the same as // what was requested, for example because the value is different AccordingToSpec bool // Valid means that the transaction is valid Valid bool // The actual value received Value string // The contract used in case of tokens Contract string // The address the transaction was actually sent Address string Message *Message Transaction *TransactionToValidate }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
identity
|
|
internal
|
|
Package sqlite is responsible for creation of encrypted sqlite3 database using sqlcipher driver.
|
Package sqlite is responsible for creation of encrypted sqlite3 database using sqlcipher driver. |