Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateAlias(id string) (string, error)
- func Identicon(id string) (string, error)
- func WithDatasync() func(c *config) error
- type Chat
- type ChatMember
- type ChatMembershipUpdate
- type ChatType
- type Contact
- type ContactDeviceInfo
- type Message
- type Messenger
- func (m *Messenger) AddMailserver(enode string) error
- func (m *Messenger) AddMembersToChat(ctx context.Context, chat *Chat, members []*ecdsa.PublicKey) error
- func (m *Messenger) AddSystemMessages(messages []*Message) ([]*Message, error)
- func (m *Messenger) BlockContact(contact Contact) ([]*Chat, error)
- func (m *Messenger) Chats() ([]*Chat, error)
- func (m *Messenger) ConfirmJoiningGroup(ctx context.Context, chat *Chat) error
- func (m *Messenger) ConfirmMessagesProcessed(messageIDs [][]byte) error
- func (m *Messenger) Contacts() ([]*Contact, error)
- func (m *Messenger) CreateGroupChat(name string) (*Chat, 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) EnableInstallation(id string) error
- func (m *Messenger) Init() error
- func (m *Messenger) Installations() ([]*multidevice.Installation, error)
- func (m *Messenger) Join(chat Chat) error
- func (m *Messenger) Leave(chat Chat) error
- func (m *Messenger) LoadFilters(filters []*transport.Filter) ([]*transport.Filter, error)
- func (m *Messenger) Mailservers() ([]string, error)
- func (m *Messenger) MarkMessagesSeen(chatID string, ids []string) 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) ReSendChatMessage(ctx context.Context, messageID string) (*MessengerResponse, error)
- func (m *Messenger) RemoveFilters(filters []*transport.Filter) error
- func (m *Messenger) RemoveMailserver(id string) error
- func (m *Messenger) RequestHistoricMessages(ctx context.Context, peer []byte, from, to uint32, cursor []byte) ([]byte, 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) SendRaw(ctx context.Context, chat Chat, data []byte) ([]byte, error)
- func (m *Messenger) SetInstallationMetadata(id string, data *multidevice.InstallationMetadata) error
- func (m *Messenger) Shutdown() (err error)
- func (m *Messenger) UpdateMessageOutgoingStatus(id, newOutgoingStatus string) error
- func (m *Messenger) VerifyENSNames(rpcEndpoint, contractAddress string, ensDetails []enstypes.ENSDetails) (map[string]enstypes.ENSResponse, 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 WithOnNewInstallationsHandler(h func([]*multidevice.Installation)) Option
- type QuotedMessage
- type RawResponse
Constants ¶
const ( OutgoingStatusSending = "sending" OutgoingStatusSent = "sent" )
const PubKeyStringLength = 132
Variables ¶
var ( ErrChatIDEmpty = errors.New("chat ID is empty") 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 WithDatasync ¶
func WithDatasync() 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"`
// Only filled for one to one chats
PublicKey *ecdsa.PublicKey `json:"-"`
// 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 []byte `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 []ChatMembershipUpdate `json:"membershipUpdates"`
}
func CreatePublicChat ¶
func (*Chat) MarshalJSON ¶ added in v1.0.0
func (*Chat) UnmarshalJSON ¶ added in v1.0.0
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 (i.e changed-name, added-member, etc)
Type string `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 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"`
// 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 int64 `json:"ensVerifiedAt"`
// 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 int64 `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"`
}
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 ¶
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 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"`
RetryCount int `json:"retryCount"`
Seen bool `json:"seen"`
OutgoingStatus string `json:"outgoingStatus,omitempty"`
QuotedMessage *QuotedMessage `json:"quotedMessage"`
// Computed fields
RTL bool `json:"rtl"`
ParsedText []byte `json:"parsedText"`
LineCount int `json:"lineCount"`
SigPubKey *ecdsa.PublicKey `json:"-"`
// RawPayload is the marshaled payload, used for resending the message
RawPayload []byte `json:"-"`
}
Message represents a message record in the database, more specifically in user_messages_legacy table.
func (*Message) MarshalJSON ¶ added in v1.0.0
func (*Message) PrepareContent ¶ added in v1.0.0
PrepareContent return the parsed content of the message, the line-count and whether is a right-to-left message
func (*Message) UnmarshalJSON ¶ added in v1.0.0
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) AddMailserver ¶
NOT IMPLEMENTED
func (*Messenger) AddMembersToChat ¶
func (*Messenger) AddSystemMessages ¶ added in v1.0.0
AddSystemMessages format an array of system-messages and saves them to the database It's needed until group chats are fully in status-go.
func (*Messenger) ConfirmJoiningGroup ¶
func (*Messenger) ConfirmMessagesProcessed ¶
DEPRECATED
func (*Messenger) CreateGroupChat ¶
TODO: consider moving to a ChatManager ???
func (*Messenger) DeleteChat ¶
func (*Messenger) DeleteMessage ¶
DEPRECATED: required by status-react.
func (*Messenger) DeleteMessagesByChatID ¶
DEPRECATED: required by status-react.
func (*Messenger) DisableInstallation ¶
func (*Messenger) EnableInstallation ¶
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, error)
func (*Messenger) LoadFilters ¶
DEPRECATED
func (*Messenger) MarkMessagesSeen ¶
DEPRECATED: required by status-react.
func (*Messenger) MessageByChatID ¶
DEPRECATED: required by status-react.
func (*Messenger) MessageByID ¶
DEPRECATED: required by status-react.
func (*Messenger) MessagesExist ¶
DEPRECATED: required by status-react.
func (*Messenger) ReSendChatMessage ¶ added in v1.0.0
func (m *Messenger) ReSendChatMessage(ctx context.Context, messageID string) (*MessengerResponse, error)
ReSendChatMessage pulls a message from the database and sends it again
func (*Messenger) RemoveFilters ¶
DEPRECATED
func (*Messenger) RemoveMailserver ¶
NOT IMPLEMENTED
func (*Messenger) RequestHistoricMessages ¶
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 ¶
DEPRECATED: required by status-react.
func (*Messenger) SelectMailserver ¶
NOT IMPLEMENTED
func (*Messenger) SendChatMessage ¶ added in v1.0.0
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) SendRaw ¶
SendRaw takes encoded data, encrypts it and sends through the wire. DEPRECATED
func (*Messenger) SetInstallationMetadata ¶
func (m *Messenger) SetInstallationMetadata(id string, data *multidevice.InstallationMetadata) error
func (*Messenger) UpdateMessageOutgoingStatus ¶
DEPRECATED: required by status-react.
func (*Messenger) VerifyENSNames ¶
func (m *Messenger) VerifyENSNames(rpcEndpoint, contractAddress string, ensDetails []enstypes.ENSDetails) (map[string]enstypes.ENSResponse, error)
VerifyENSNames verifies that a registered ENS name matches the expected public key
type MessengerResponse ¶ added in v1.0.0
type MessengerResponse struct {
Chats []*Chat `json:"chats,omitEmpty"`
Messages []*Message `json:"messages,omitEmpty"`
Contacts []*Contact `json:"contacts,omitEmpty"`
// Raw unprocessed messages
RawMessages []*RawResponse `json:"rawMessages,omitEmpty"`
}
func (*MessengerResponse) IsEmpty ¶ added in v1.0.0
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 WithOnNewInstallationsHandler ¶
func WithOnNewInstallationsHandler(h func([]*multidevice.Installation)) Option
type QuotedMessage ¶
type QuotedMessage struct {
// From is a public key of the author of the message.
From string `json:"from"`
Text string `json:"text"`
}
QuotedMessage contains the original text of the message replied to
type RawResponse ¶ added in v1.0.0
type RawResponse struct {
Filter *transport.Filter `json:"filter"`
Messages []*v1protocol.StatusMessage `json:"messages"`
}
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. |
|
transport
|
|