dm

package
v4.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: BSD-2-Clause, BSD-2-Clause Imports: 46 Imported by: 3

Documentation

Index

Constants

View Source
const (

	// SendMessageTag is the base tag used when generating a debug tag for
	// sending a message.
	SendMessageTag = "Message"

	// SendReplyTag is the base tag used when generating a debug tag for
	// sending a reply.
	SendReplyTag = "Reply"

	// SendReactionTag is the base tag used when generating a debug tag for
	// sending a reaction.
	SendReactionTag = "Reaction"

	// SendSilentTag is the base tag used when generating a debug tag for
	// sending a silent message.
	SendSilentTag = "Silent"

	// SendInviteTag is the base tag used when generating a debug tag for
	// sending an invitation.
	SendInviteTag = "Invite"

	// DeleteMessageTag is the base tag used when generating a debug tag for
	// delete message.
	DeleteMessageTag = "Delete"
)
View Source
const (

	// MaxUsesKey is the key used to save max uses in a URL. The value is
	// expected to be a positive integer.
	MaxUsesKey = "m"
)

Variables

View Source
var File_directMessages_proto protoreflect.FileDescriptor

Functions

func DecodeShareURL added in v4.6.3

func DecodeShareURL(url string, password string) (int32, nike.PublicKey, error)

DecodeShareURL decodes the given URL for information to DM another user.

func DeriveReceptionID

func DeriveReceptionID(publicKey ed25519.PublicKey, idToken uint32) *id.ID

DeriveReceptionID returns a reception ID for direct messages sent to the user. It generates this ID by hashing the public key and an arbitrary idToken together. The ID type is set to "User".

func ShareURL added in v4.6.3

func ShareURL(url string, maxUses int, token int32, key nike.PublicKey,
	csprng io.Reader) (string, error)

ShareURL generates a URL that can be used to share this channel with others on the given host.

Types

type ActionSaver added in v4.7.1

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

ActionSaver saves actions that target messages that have not been received yet and saves them until they are received to apply the action.

func NewActionSaver added in v4.7.1

func NewActionSaver(kv versioned.KV) *ActionSaver

NewActionSaver initialises a new empty ActionSaver.

func (*ActionSaver) AddAction added in v4.7.1

func (as *ActionSaver) AddAction(targetMessage message.ID, received time.Time) error

AddAction saves the action to the list.

func (*ActionSaver) CheckSavedActions added in v4.7.1

func (as *ActionSaver) CheckSavedActions(targetMessage message.ID) bool

CheckSavedActions checks if there is a saved action for the message.

func (*ActionSaver) StartProcesses added in v4.7.1

func (as *ActionSaver) StartProcesses() (stoppable.Stoppable, error)

StartProcesses starts the thread that checks for expired action leases and undoes the action. This function adheres to the [xxdk.Service] type.

This function always returns a nil error.

type Callbacks added in v4.7.1

type Callbacks interface {
	// NotificationUpdate is a callback that is called any time a notification
	// level changes.
	//
	// It returns a [NotificationFilter], which is passed into
	// [GetNotificationReportsForMe] to determine which notifications from the
	// notification server belong to the user.
	//
	// It also returns a slice that contains the [NotificationLevel] for all
	// added and changed DM conversations. The deleted slice contains any
	// conversations that have been deleted.
	NotificationUpdate(nf NotificationFilter,
		changed []NotificationState, deleted []ed25519.PublicKey)

	// BlockedUser is a callback that is called anytime a user is blocked or
	// unblocked. It is also called on initial registration for every blocked
	// user.
	BlockedUser(user ed25519.PublicKey, blocked bool)
}

Callbacks is an interface that a caller can adhere to in order to get updates when sync events occur.

type ChannelInvitation added in v4.7.1

type ChannelInvitation struct {
	Version    uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
	Text       string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"`
	InviteLink string `protobuf:"bytes,3,opt,name=inviteLink,proto3" json:"inviteLink,omitempty"`
	Password   string `protobuf:"bytes,4,opt,name=Password,proto3" json:"Password,omitempty"`
	// contains filtered or unexported fields
}

ChannelInvitation is the payload for a Invitation MessageType. It the DM partner to a channel.

func (*ChannelInvitation) Descriptor deprecated added in v4.7.1

func (*ChannelInvitation) Descriptor() ([]byte, []int)

Deprecated: Use ChannelInvitation.ProtoReflect.Descriptor instead.

func (x *ChannelInvitation) GetInviteLink() string

func (*ChannelInvitation) GetPassword added in v4.7.1

func (x *ChannelInvitation) GetPassword() string

func (*ChannelInvitation) GetText added in v4.7.1

func (x *ChannelInvitation) GetText() string

func (*ChannelInvitation) GetVersion added in v4.7.1

func (x *ChannelInvitation) GetVersion() uint32

func (*ChannelInvitation) ProtoMessage added in v4.7.1

func (*ChannelInvitation) ProtoMessage()

func (*ChannelInvitation) ProtoReflect added in v4.7.1

func (x *ChannelInvitation) ProtoReflect() protoreflect.Message

func (*ChannelInvitation) Reset added in v4.7.1

func (x *ChannelInvitation) Reset()

func (*ChannelInvitation) String added in v4.7.1

func (x *ChannelInvitation) String() string

type Client

type Client interface {
	Sender

	// GetPublicKey returns the public key of this client.
	GetPublicKey() nike.PublicKey

	// GetToken returns the DM token of this client.
	GetToken() uint32

	// GetIdentity returns the public identity associated with this client.
	GetIdentity() codename.Identity

	// ExportPrivateIdentity encrypts and exports the private identity to a
	// portable string.
	ExportPrivateIdentity(password string) ([]byte, error)

	// BlockPartner prevents receiving messages and notifications from the
	// partner.
	BlockPartner(partnerPubKey ed25519.PublicKey)

	// UnblockPartner unblocks a blocked sender to allow DM messages.
	UnblockPartner(partnerPubKey ed25519.PublicKey)

	// IsBlocked indicates if the given partner is blocked.
	IsBlocked(partnerPubKey ed25519.PublicKey) bool

	// GetBlockedPartners returns all partners who are blocked by this user.
	GetBlockedPartners() []ed25519.PublicKey

	// GetNotificationLevel returns the notification level for the given channel.
	GetNotificationLevel(
		partnerPubKey ed25519.PublicKey) (NotificationLevel, error)

	// SetMobileNotificationsLevel sets the notification level for the given DM
	// conversation partner.
	SetMobileNotificationsLevel(
		partnerPubKey ed25519.PublicKey, level NotificationLevel) error

	NickNameManager
}

Client the direct message client implements a Listener and Sender interface.

func NewDMClient

func NewDMClient(myID *codename.PrivateIdentity, receiver EventModel,
	tracker SendTracker,
	nickManager NickNameManager, nm NotificationsManager,
	net cMixClient, kv versioned.KV,
	rng *fastRNG.StreamGenerator, cbs Callbacks) (Client, error)

NewDMClient creates a new client for direct messaging. This should be called when the channels manager is created/loaded. It has no associated state, so it does not have a corresponding Load function.

The DMClient implements both the Sender and ListenerRegistrar interface. See send.go for implementation of the Sender interface.

type DeleteMessage added in v4.7.1

type DeleteMessage struct {
	Version         uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
	TargetMessageID []byte `protobuf:"bytes,2,opt,name=targetMessageID,proto3" json:"targetMessageID,omitempty"`
	// contains filtered or unexported fields
}

DeleteMessage is the payload for a Delete MessageType. It is used to delete an existing message.

func (*DeleteMessage) Descriptor deprecated added in v4.7.1

func (*DeleteMessage) Descriptor() ([]byte, []int)

Deprecated: Use DeleteMessage.ProtoReflect.Descriptor instead.

func (*DeleteMessage) GetTargetMessageID added in v4.7.1

func (x *DeleteMessage) GetTargetMessageID() []byte

func (*DeleteMessage) GetVersion added in v4.7.1

func (x *DeleteMessage) GetVersion() uint32

func (*DeleteMessage) ProtoMessage added in v4.7.1

func (*DeleteMessage) ProtoMessage()

func (*DeleteMessage) ProtoReflect added in v4.7.1

func (x *DeleteMessage) ProtoReflect() protoreflect.Message

func (*DeleteMessage) Reset added in v4.7.1

func (x *DeleteMessage) Reset()

func (*DeleteMessage) String added in v4.7.1

func (x *DeleteMessage) String() string

type DirectMessage

type DirectMessage struct {

	// The round this message was sent on to the intended recipient
	RoundID uint64 `protobuf:"varint,1,opt,name=RoundID,proto3" json:"RoundID,omitempty"`
	// The round this message was sent on for the self send.
	SelfRoundID uint64 `protobuf:"varint,2,opt,name=SelfRoundID,proto3" json:"SelfRoundID,omitempty"`
	DMToken     uint32 `protobuf:"varint,3,opt,name=DMToken,proto3" json:"DMToken,omitempty"` // hash of private key of the sender
	// The type the below payload is (currently a Text or Reaction)
	PayloadType uint32 `protobuf:"varint,4,opt,name=PayloadType,proto3" json:"PayloadType,omitempty"`
	// Payload is the actual message payload. It will be processed differently
	// based on the PayloadType.
	Payload []byte `protobuf:"bytes,5,opt,name=Payload,proto3" json:"Payload,omitempty"`
	// nickname is the name which the user is using for this message it will not
	// be longer than 24 characters.
	Nickname string `protobuf:"bytes,6,opt,name=Nickname,proto3" json:"Nickname,omitempty"`
	// Nonce is 32 bits of randomness to ensure that two messages in the same
	// round with that have the same nickname, payload, and lease will not have
	// the same message ID.
	Nonce []byte `protobuf:"bytes,7,opt,name=Nonce,proto3" json:"Nonce,omitempty"`
	// LocalTimestamp is the timestamp when the "send call" is made based upon
	// the local clock. If this differs by more than 5 seconds +/- from when the
	// round it sent on is queued, then a random mutation on the queued time
	// (+/- 200ms) will be used by local clients instead.
	LocalTimestamp int64 `protobuf:"varint,8,opt,name=LocalTimestamp,proto3" json:"LocalTimestamp,omitempty"`
	// contains filtered or unexported fields
}

DirectMessage is a message sent directly from one user to another. It includes the return information (public key and DMToken) for the sender.

func (*DirectMessage) Descriptor deprecated

func (*DirectMessage) Descriptor() ([]byte, []int)

Deprecated: Use DirectMessage.ProtoReflect.Descriptor instead.

func (*DirectMessage) GetDMToken

func (x *DirectMessage) GetDMToken() uint32

func (*DirectMessage) GetLocalTimestamp

func (x *DirectMessage) GetLocalTimestamp() int64

func (*DirectMessage) GetNickname

func (x *DirectMessage) GetNickname() string

func (*DirectMessage) GetNonce

func (x *DirectMessage) GetNonce() []byte

func (*DirectMessage) GetPayload

func (x *DirectMessage) GetPayload() []byte

func (*DirectMessage) GetPayloadType

func (x *DirectMessage) GetPayloadType() uint32

func (*DirectMessage) GetRoundID

func (x *DirectMessage) GetRoundID() uint64

func (*DirectMessage) GetSelfRoundID

func (x *DirectMessage) GetSelfRoundID() uint64

func (*DirectMessage) ProtoMessage

func (*DirectMessage) ProtoMessage()

func (*DirectMessage) ProtoReflect

func (x *DirectMessage) ProtoReflect() protoreflect.Message

func (*DirectMessage) Reset

func (x *DirectMessage) Reset()

func (*DirectMessage) String

func (x *DirectMessage) String() string

type EventModel

type EventModel interface {
	// Receive is called whenever a raw direct message is
	// received. It may be called multiple times on the same
	// message. It is incumbent on the user of the API to filter
	// such called by message ID.
	//
	// Receive includes the message Type so that the implementor
	// can determine what to do with the message.
	//
	// The API needs to return a UUID of the message that can be
	// referenced at a later time.
	//
	// messageID, timestamp, and round are all nillable and may be
	// updated based upon the UUID at a later date. A time of
	// time.Time{} will be passed for a nilled timestamp.
	//
	// Nickname may be empty, in which case the UI is expected to
	// display the codename.
	Receive(messageID cryptoMessage.ID,
		nickname string, text []byte,
		partnerPubKey, senderPubKey ed25519.PublicKey,
		partnerToken uint32,
		codeset uint8, timestamp time.Time,
		round rounds.Round, mType MessageType, status Status) uint64

	// ReceiveText is called whenever a direct message is
	// received. It may be called multiple times on the same
	// message. It is incumbent on the user of the API to filter
	// such called by message ID.
	//
	// The API needs to return a UUID of the message that can be
	// referenced at a later time.
	//
	// messageID, timestamp, and round are all nillable and may be
	// updated based upon the UUID at a later date. A time of
	// time.Time{} will be passed for a nilled timestamp.
	//
	// Nickname may be empty, in which case the UI is expected to
	// display the codename.
	ReceiveText(messageID cryptoMessage.ID,
		nickname, text string,
		partnerPubKey, senderPubKey ed25519.PublicKey,
		partnerToken uint32,
		codeset uint8, timestamp time.Time,
		round rounds.Round, status Status) uint64

	// ReceiveReply is called whenever a direct message is
	// received that is a reply. It may be called multiple times
	// on the same message. It is incumbent on the user of the API
	// to filter such called by message ID.
	//
	// Messages may arrive our of order, so a reply, in theory,
	// can arrive before the initial message. As a result, it may
	// be important to buffer replies.
	//
	// The API needs to return a UUID of the message that can be
	// referenced at a later time.
	//
	// messageID, timestamp, and round are all nillable and may be
	// updated based upon the UUID at a later date. A time of
	// time.Time{} will be passed for a nilled timestamp.
	//
	// Nickname may be empty, in which case the UI is expected to
	// display the codename.
	ReceiveReply(messageID cryptoMessage.ID,
		reactionTo cryptoMessage.ID, nickname, text string,
		partnerPubKey, senderPubKey ed25519.PublicKey,
		partnerToken uint32, codeset uint8,
		timestamp time.Time, round rounds.Round,
		status Status) uint64

	// ReceiveReaction is called whenever a reaction to a direct
	// message is received. It may be called multiple times on the
	// same reaction. It is incumbent on the user of the API to
	// filter such called by message ID.
	//
	// Messages may arrive our of order, so a reply, in theory,
	// can arrive before the initial message. As a result, it may
	// be important to buffer replies.
	//
	// The API needs to return a UUID of the message that can be
	// referenced at a later time.
	//
	// messageID, timestamp, and round are all nillable and may be
	// updated based upon the UUID at a later date. A time of
	// time.Time{} will be passed for a nilled timestamp.
	//
	// Nickname may be empty, in which case the UI is expected to
	// display the codename.
	ReceiveReaction(messageID cryptoMessage.ID,
		reactionTo cryptoMessage.ID, nickname, reaction string,
		partnerPubKey, senderPubKey ed25519.PublicKey,
		partnerToken uint32, codeset uint8,
		timestamp time.Time, round rounds.Round,
		status Status) uint64

	// UpdateSentStatus is called whenever the sent status of a message has
	// changed.
	//
	// messageID, timestamp, and round are all nillable and may be
	// updated based upon the UUID at a later date. A time of
	// time.Time{} will be passed for a nilled timestamp. If a nil
	// value is passed, make no update.
	UpdateSentStatus(uuid uint64, messageID cryptoMessage.ID,
		timestamp time.Time, round rounds.Round, status Status)

	// DeleteMessage deletes the message with the given message.ID belonging to
	// the sender. If the message exists and belongs to the sender, then it is
	// deleted and DeleteMessage returns true. If it does not exist, it returns
	// false.
	DeleteMessage(messageID cryptoMessage.ID, senderPubKey ed25519.PublicKey) bool

	// GetConversation returns any conversations held by the
	// model (receiver)
	GetConversation(senderPubKey ed25519.PublicKey) *ModelConversation

	// GetConversations returns any conversations held by the
	// model (receiver)
	GetConversations() []ModelConversation
}

EventModel is all of the reception functions an API user must implement. This is similar to the event model system in channels.

type MessageType

type MessageType uint16

MessageType is the type of message being sent to a channel.

const (
	// TextType is the default type for a message. It denotes that the
	// message only contains text.
	TextType MessageType = 1

	// ReplyType denotes that the message is a reply to another message.
	ReplyType MessageType = 2

	// ReactionType denotes that the message is a reaction to another message.
	ReactionType MessageType = 3

	// SilentType denotes that the message is a silent message which should not
	// notify the user in any way.
	SilentType MessageType = 4

	// InvitationType denotes that the message is an invitation to another
	// channel.
	InvitationType MessageType = 5

	// DeleteType denotes that the message contains the ID of a message to
	// delete.
	DeleteType MessageType = 6
)

func UnmarshalMessageType added in v4.7.1

func UnmarshalMessageType(b [2]byte) MessageType

UnmarshalMessageType returns the MessageType from its byte representation.

func (MessageType) Marshal added in v4.7.1

func (mt MessageType) Marshal() [2]byte

Marshal returns the byte representation of the MessageType.

func (MessageType) String

func (mt MessageType) String() string

String returns a human-readable version of MessageType, used for debugging and logging. This function adheres to the fmt.Stringer interface.

type ModelConversation added in v4.5.0

type ModelConversation struct {
	Pubkey         []byte `json:"pub_key"`
	Nickname       string `json:"nickname"`
	Token          uint32 `json:"token"`
	CodesetVersion uint8  `json:"codeset_version"`

	// Deprecated: KV is the source of truth for blocked users.
	BlockedTimestamp *time.Time `json:"blocked_timestamp"`
}

type NickNameManager

type NickNameManager interface {
	// GetNickname gets the nickname associated with this DM user.
	GetNickname() (string, bool)
	// SetNickname sets the nickname to use for this user.
	SetNickname(nick string) error
}

NickNameManager interface is an object that handles the mapping of nicknames to cMix reception IDs.

func NewNicknameManager

func NewNicknameManager(id *id.ID, ekv versioned.KV) NickNameManager

type NotificationFilter added in v4.7.1

type NotificationFilter struct {
	// Identifier is this user's public key. It is set by a partner on the
	// message.CompressedService when sending a DM message.
	Identifier []byte `json:"identifier"`

	// MyID is this user's reception ID.
	MyID *id.ID `json:"myID"`

	// Tags is a list of all SIH tags for each DM partner. It is used to ensure
	// a received notification is from a valid DM partner.
	Tags []string `json:"tags"`

	// PublicKeys is a map of tags to their public keys. Used to identify the
	// owner of the message triggering a notification.
	PublicKeys map[string]ed25519.PublicKey `json:"publicKeys"`

	// List of MessageType to notify on.
	AllowedTypes map[MessageType]struct{} `json:"allowedTypes"`
}

NotificationFilter defines filtering properties for DM message notifications.

These will be tested against every received notification. The notification, which is encrypted, will not be decrypted properly unless the identifier is correct. As a result, the identifier will be tested against a garbled message, and the probability of false collisions is simply the random chance that all bloom bits are flipped.

Given that K = 26 (see elixxir/crypto/sih/evaluatable.go), the collision chance is 1/2^26. The message types would also need to collide given that in the 16-bit space there are only expected to be a small number of messages that are valid notifications, the collision chance increases by ~20/2^16.

Given this information, the number of evaluations where a user has a 50% chance of a false notification can be calculated as (x = ln(.5)/ln(1-p)) where p = (1/2^26) * (1/2^10), x = 1.5 * 10^11, assuming a user is registered in 100 channels and received 100,000 total notifications a day, this number of events would occur after 15,243 days, which is the mean time to false notification through this system. This number is very acceptable.

type NotificationLevel added in v4.7.1

type NotificationLevel uint8

NotificationLevel specifies what level of notifications should be received for a channel.

const (
	// NotifyNone results in no notifications.
	NotifyNone NotificationLevel = 10

	// NotifyAll results in notifications from all messages except silent ones.
	NotifyAll NotificationLevel = 40
)

func UnmarshalNotificationLevel added in v4.7.1

func UnmarshalNotificationLevel(b []byte) NotificationLevel

UnmarshalNotificationLevel unmarshalls the byte slice into a NotificationLevel.

func (NotificationLevel) Marshal added in v4.7.1

func (nl NotificationLevel) Marshal() []byte

Marshal returns the byte representation of the NotificationLevel.

func (NotificationLevel) String added in v4.7.1

func (nl NotificationLevel) String() string

String prints a human-readable form of the NotificationLevel for logging and debugging. This function adheres to the fmt.Stringer interface.

type NotificationReport added in v4.7.1

type NotificationReport struct {
	// Public key of DM partner.
	Partner ed25519.PublicKey `json:"partner"`

	// Type is the MessageType of the message that the notification belongs to.
	Type MessageType `json:"type"`
}

NotificationReport describes information about a single notification belonging to the user.

func GetNotificationReportsForMe added in v4.7.1

func GetNotificationReportsForMe(nf NotificationFilter,
	notificationData []*primNotif.Data) []NotificationReport

GetNotificationReportsForMe checks the notification data against the filter list to determine which notifications belong to the user. A list of notification reports is returned detailing all notifications for the user.

type NotificationState added in v4.7.1

type NotificationState struct {
	// PubKey is the Ed25519 public key of the DM conversation partner.
	PubKey ed25519.PublicKey `json:"pubKey"`

	// Level is the notification level for the DM conversation.
	Level NotificationLevel `json:"level"`
}

NotificationState contains information about the notifications for a DM conversation.

type NotificationUpdate added in v4.7.1

type NotificationUpdate func(nf NotificationFilter,
	changed []NotificationState, deleted []ed25519.PublicKey)

NotificationUpdate is a callback that is called any time a notification level changes.

It returns a NotificationFilter, which is passed into GetNotificationReportsForMe to determine which notifications from the notification server belong to the user.

It also returns a slice that contains the NotificationLevel for all added and changed DM conversations. The deleted slice contains any conversations that have been deleted.

type NotificationsManager added in v4.7.1

type NotificationsManager interface {
	Set(toBeNotifiedOn *id.ID, group string, metadata []byte,
		status clientNotif.NotificationState) error
}

NotificationsManager contains the methods from [notifications.Manager] that are required by the [Manager].

type Reaction

type Reaction struct {
	Version           uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
	Reaction          string `protobuf:"bytes,2,opt,name=reaction,proto3" json:"reaction,omitempty"`
	ReactionMessageID []byte `protobuf:"bytes,3,opt,name=reactionMessageID,proto3" json:"reactionMessageID,omitempty"`
	// contains filtered or unexported fields
}

Reaction is the payload for reactions. The reaction must be a single emoji and the reactionMessageID must be non nil and a real message in the channel.

func (*Reaction) Descriptor deprecated

func (*Reaction) Descriptor() ([]byte, []int)

Deprecated: Use Reaction.ProtoReflect.Descriptor instead.

func (*Reaction) GetReaction

func (x *Reaction) GetReaction() string

func (*Reaction) GetReactionMessageID

func (x *Reaction) GetReactionMessageID() []byte

func (*Reaction) GetVersion

func (x *Reaction) GetVersion() uint32

func (*Reaction) ProtoMessage

func (*Reaction) ProtoMessage()

func (*Reaction) ProtoReflect

func (x *Reaction) ProtoReflect() protoreflect.Message

func (*Reaction) Reset

func (x *Reaction) Reset()

func (*Reaction) String

func (x *Reaction) String() string

type ReceiverBuilder

type ReceiverBuilder func(path string) (EventModel, error)

ReceiverBuilder initialises the event model using the given path.

type SendTracker

type SendTracker interface {
	// Init is used by the DM Client to register trigger and
	// update functions and start send tracking
	Init(net cMixClient, trigger triggerEventFunc,
		updateStatus updateStatusFunc, rng *fastRNG.StreamGenerator)

	// DenotePendingSend registers a new message to be tracked for sending
	DenotePendingSend(partnerPublicKey, senderPubKey ed25519.PublicKey,
		partnerToken uint32,
		messageType MessageType,
		msg *DirectMessage) (uuid uint64, err error)

	// FailedSend marks a message failed
	FailedSend(uuid uint64) error

	// Sent marks a message successfully Sent
	Sent(uuid uint64, msgID cryptoMessage.ID, round rounds.Round) error

	// CheckIfSent checks if the given message was a sent message
	CheckIfSent(messageID cryptoMessage.ID, r rounds.Round) bool

	// Delivered marks a message delivered
	Delivered(msgID cryptoMessage.ID, round rounds.Round) bool

	// StopTracking stops tracking a message
	StopTracking(msgID cryptoMessage.ID, round rounds.Round) bool
}

SendTracker provides facilities for tracking sent messages

func NewSendTracker

func NewSendTracker(kv versioned.KV) SendTracker

NewSendTracker returns an uninitialized SendTracker object. The DM Client will call Init to initialize it.

type Sender

type Sender interface {
	// SendText is used to send a formatted message to another user.
	SendText(partnerPubKey ed25519.PublicKey, partnerToken uint32,
		msg string, params cmix.CMIXParams) (
		cryptoMessage.ID, rounds.Round, ephemeral.Id, error)

	// SendReply is used to send a formatted direct message reply.
	//
	// If the message ID that the reply is sent to does not exist,
	// then the other side will post the message as a normal
	// message and not as a reply.
	SendReply(partnerPubKey ed25519.PublicKey, partnerToken uint32,
		msg string, replyTo cryptoMessage.ID,
		params cmix.CMIXParams) (cryptoMessage.ID, rounds.Round,
		ephemeral.Id, error)

	// SendReaction is used to send a reaction to a direct
	// message. The reaction must be a single emoji with no other
	// characters, and will be rejected otherwise.
	//
	// Clients will drop the reaction if they do not recognize the reactTo
	// message.
	SendReaction(partnerPubKey ed25519.PublicKey, partnerToken uint32,
		reaction string, reactTo cryptoMessage.ID,
		params cmix.CMIXParams) (cryptoMessage.ID, rounds.Round,
		ephemeral.Id, error)

	// SendInvite is used to send to a DM partner an invitation to another
	// channel.
	SendInvite(partnerPubKey ed25519.PublicKey,
		partnerToken uint32, msg string, inviteTo *cryptoBroadcast.Channel,
		host string, params cmix.CMIXParams) (
		cryptoMessage.ID, rounds.Round, ephemeral.Id, error)

	// SendSilent is used to send to a channel a message with no notifications.
	// Its primary purpose is to communicate new nicknames without calling
	// SendMessage.
	//
	// It takes no payload intentionally as the message should be very
	// lightweight.
	SendSilent(partnerPubKey ed25519.PublicKey, partnerToken uint32,
		params cmix.CMIXParams) (
		cryptoMessage.ID, rounds.Round, ephemeral.Id, error)

	// DeleteMessage sends a message to the partner to delete a message this
	// user sent. Also deletes it from the local database.
	DeleteMessage(partnerPubKey ed25519.PublicKey, partnerToken uint32,
		targetMessage cryptoMessage.ID, params cmix.CMIXParams) (
		cryptoMessage.ID, rounds.Round, ephemeral.Id, error)

	// Send is used to send a raw message. In general, it
	// should be wrapped in a function that defines the wire protocol.
	//
	// If the final message, before being sent over the wire, is
	// too long, this will return an error. Due to the underlying
	// encoding using compression, it is not possible to define
	// the largest payload that can be sent, but it will always be
	// possible to send a payload of 802 bytes at a minimum.
	Send(partnerPubKey ed25519.PublicKey, partnerToken uint32,
		messageType MessageType, plaintext []byte,
		params cmix.CMIXParams) (cryptoMessage.ID,
		rounds.Round, ephemeral.Id, error)
}

Sender implementers allow the API user to send to a given partner over cMix.

type SilentMessage added in v4.7.1

type SilentMessage struct {
	Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
	// contains filtered or unexported fields
}

SilentMessage is the payload for a Silent MessageType. Its primary purpose is to communicate new nicknames without sending a Text.

func (*SilentMessage) Descriptor deprecated added in v4.7.1

func (*SilentMessage) Descriptor() ([]byte, []int)

Deprecated: Use SilentMessage.ProtoReflect.Descriptor instead.

func (*SilentMessage) GetVersion added in v4.7.1

func (x *SilentMessage) GetVersion() uint32

func (*SilentMessage) ProtoMessage added in v4.7.1

func (*SilentMessage) ProtoMessage()

func (*SilentMessage) ProtoReflect added in v4.7.1

func (x *SilentMessage) ProtoReflect() protoreflect.Message

func (*SilentMessage) Reset added in v4.7.1

func (x *SilentMessage) Reset()

func (*SilentMessage) String added in v4.7.1

func (x *SilentMessage) String() string

type Status

type Status uint8

Status represents the current status of a channel message.

const (
	// Unsent is the status of a message when it is pending to be sent.
	Unsent Status = iota

	// Sent is the status of a message once the round it is sent on completes.
	Sent

	// Received is the status of a message once is has been received.
	Received

	// Failed is the status of a message if it failed to send.
	Failed
)

func (Status) String

func (ss Status) String() string

String returns a human-readable version of [SentStatus], used for debugging and logging. This function adheres to the fmt.Stringer interface.

type Text

type Text struct {
	Version        uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
	Text           string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"`
	ReplyMessageID []byte `protobuf:"bytes,3,opt,name=replyMessageID,proto3" json:"replyMessageID,omitempty"`
	// contains filtered or unexported fields
}

Text is the payload for sending normal text messages the replyMessageID is nil when it is not a reply.

func (*Text) Descriptor deprecated

func (*Text) Descriptor() ([]byte, []int)

Deprecated: Use Text.ProtoReflect.Descriptor instead.

func (*Text) GetReplyMessageID

func (x *Text) GetReplyMessageID() []byte

func (*Text) GetText

func (x *Text) GetText() string

func (*Text) GetVersion

func (x *Text) GetVersion() uint32

func (*Text) ProtoMessage

func (*Text) ProtoMessage()

func (*Text) ProtoReflect

func (x *Text) ProtoReflect() protoreflect.Message

func (*Text) Reset

func (x *Text) Reset()

func (*Text) String

func (x *Text) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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