Documentation ¶
Index ¶
- Variables
- func DefaultConfConfig() cmd.ConfConfig
- type Config
- type Mail
- type Mailbox
- func (m *Mailbox) DeleteInboxMessage(ctx context.Context, id string) error
- func (m *Mailbox) DeleteSentboxMessage(ctx context.Context, id string) error
- func (m *Mailbox) Identity() thread.Identity
- func (m *Mailbox) ListInboxMessages(ctx context.Context, opts ...client.ListOption) ([]client.Message, error)
- func (m *Mailbox) ListSentboxMessages(ctx context.Context, opts ...client.ListOption) ([]client.Message, error)
- func (m *Mailbox) ReadInboxMessage(ctx context.Context, id string) error
- func (m *Mailbox) SendMessage(ctx context.Context, to thread.PubKey, body []byte) (msg client.Message, err error)
- func (m *Mailbox) WatchInbox(ctx context.Context, mevents chan<- MailboxEvent, offline bool) (<-chan cmd.WatchState, error)
- func (m *Mailbox) WatchSentbox(ctx context.Context, mevents chan<- MailboxEvent, offline bool) (<-chan cmd.WatchState, error)
- type MailboxEvent
- type MailboxEventType
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotAMailbox indicates the given path is not within a mailbox. ErrNotAMailbox = errors.New("not a mailbox (or any of the parent directories): .textile") // ErrMailboxExists is used during initialization to indicate the path already contains a mailbox. ErrMailboxExists = errors.New("mailbox is already initialized") // ErrIdentityRequired indicates the operation requires a thread Identity but none was given. ErrIdentityRequired = errors.New("thread Identity is required") // ErrAPIKeyRequired indicates the operation requires am API keybut none was given. ErrAPIKeyRequired = errors.New("api key is required") )
Functions ¶
func DefaultConfConfig ¶
func DefaultConfConfig() cmd.ConfConfig
DefaultConfConfig returns the default ConfConfig.
Types ¶
type Config ¶
type Config struct { // Path is the path in which the new mailbox should be created (required). Path string // Identity is the thread.Identity of the mailbox owner (required). // It's value may be inflated from a --identity flag or {EnvPrefix}_IDENTITY env variable. Identity thread.Identity // APIKey is hub API key (required). // It's value may be inflated from a --api-key flag or {EnvPrefix}_API_KEY env variable. APIKey string // APISecret is hub API key secret (optional). // It's value may be inflated from a --api-secret flag or {EnvPrefix}_API_SECRET env variable. APISecret string }
Config contains details for a new local mailbox.
type Mail ¶
type Mail struct {
// contains filtered or unexported fields
}
Mail is used to create new mailboxes based on the provided clients and config.
func NewMail ¶
func NewMail(clients *cmd.Clients, config cmd.ConfConfig) *Mail
NewMail creates Mail from clients and config.
func (*Mail) GetLocalMailbox ¶
GetLocalMailbox loads and returns the mailbox at path if it exists.
func (*Mail) NewConfigFromCmd ¶
NewConfigFromCmd returns a config by inflating values from the given cobra command and path. First, flags for "identity", "api_key", and "api_secret" are used if they exist. If still unset, the env vars {EnvPrefix}_IDENTITY, {EnvPrefix}_API_KEY, and {EnvPrefix}_API_SECRET are used.
type Mailbox ¶
type Mailbox struct {
// contains filtered or unexported fields
}
Mailbox is a local-first messaging library built on ThreadDB and IPFS.
func (*Mailbox) DeleteInboxMessage ¶
DeleteInboxMessage deletes an inbox message by ID.
func (*Mailbox) DeleteSentboxMessage ¶
DeleteSentboxMessage deletes a sent message by ID.
func (*Mailbox) ListInboxMessages ¶
func (m *Mailbox) ListInboxMessages(ctx context.Context, opts ...client.ListOption) ([]client.Message, error)
ListInboxMessages lists messages from the inbox. Use options to paginate with seek and limit, and filter by read status.
func (*Mailbox) ListSentboxMessages ¶
func (m *Mailbox) ListSentboxMessages(ctx context.Context, opts ...client.ListOption) ([]client.Message, error)
ListSentboxMessages lists messages from the sentbox. Use options to paginate with seek and limit.
func (*Mailbox) ReadInboxMessage ¶
ReadInboxMessage marks a message as read by ID.
func (*Mailbox) SendMessage ¶
func (m *Mailbox) SendMessage(ctx context.Context, to thread.PubKey, body []byte) (msg client.Message, err error)
SendMessage sends the message body to a recipient.
func (*Mailbox) WatchInbox ¶
func (m *Mailbox) WatchInbox(ctx context.Context, mevents chan<- MailboxEvent, offline bool) (<-chan cmd.WatchState, error)
WatchInbox watches the inbox for new mailbox events. If offline is true, this will keep watching during network interruptions. Returns a channel of watch connectivity states. Cancel context to stop watching.
func (*Mailbox) WatchSentbox ¶
func (m *Mailbox) WatchSentbox(ctx context.Context, mevents chan<- MailboxEvent, offline bool) (<-chan cmd.WatchState, error)
WatchSentbox watches the sentbox for new mailbox events. If offline is true, this will keep watching during network interruptions. Returns a channel of watch connectivity states. Cancel context to stop watching.
type MailboxEvent ¶
type MailboxEvent struct { // Type of event. Type MailboxEventType // Message identifier. MessageID db.InstanceID // Message will contain the full message unless this is a delete event. Message client.Message }
MailboxEvent describes an event that occurred in a mailbox.
type MailboxEventType ¶
type MailboxEventType int
MailboxEventType is the type of mailbox event.
const ( // NewMessage indicates the mailbox has a new message. NewMessage MailboxEventType = iota // MessageRead indicates a message was read in the mailbox. MessageRead // MessageDeleted indicates a message was deleted from the mailbox. MessageDeleted )