client

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides the client api.

func NewClient

func NewClient(target string, opts ...grpc.DialOption) (*Client, error)

NewClient starts the client.

func (*Client) Close

func (c *Client) Close() error

Close closes the client's grpc connection and cancels any active requests.

func (*Client) DeleteInboxMessage added in v1.0.14

func (c *Client) DeleteInboxMessage(ctx context.Context, id string) error

DeleteInboxMessage deletes an inbox message by ID.

func (*Client) DeleteSentboxMessage added in v1.0.14

func (c *Client) DeleteSentboxMessage(ctx context.Context, id string) error

DeleteSentboxMessage deletes a sent message by ID.

func (*Client) GetThread

func (c *Client) GetThread(ctx context.Context, name string) (*pb.GetThreadReply, error)

GetThread returns a thread by name.

func (*Client) ListInboxMessages added in v1.0.14

func (c *Client) ListInboxMessages(ctx context.Context, opts ...ListOption) ([]Message, error)

ListInboxMessages lists messages from the inbox. Use options to paginate with seek and limit and filter by read status.

func (*Client) ListSentboxMessages added in v1.0.14

func (c *Client) ListSentboxMessages(ctx context.Context, opts ...ListOption) ([]Message, error)

ListSentboxMessages lists messages from the sentbox. Use options to paginate with seek and limit.

func (*Client) ListThreads

func (c *Client) ListThreads(ctx context.Context) (*pb.ListThreadsReply, error)

ListThreads returns a list of threads. Threads can be created using the threads or threads network client.

func (*Client) ReadInboxMessage added in v1.0.14

func (c *Client) ReadInboxMessage(ctx context.Context, id string) error

ReadInboxMessage marks a message as read by ID.

func (*Client) SendMessage added in v1.0.14

func (c *Client) SendMessage(ctx context.Context, from thread.Identity, to thread.PubKey, body []byte) (msg Message, err error)

SendMessage sends the message body to a recipient.

func (*Client) SetupMailbox added in v1.0.14

func (c *Client) SetupMailbox(ctx context.Context) (mailbox thread.ID, err error)

SetupMailbox creates inbox and sentbox threads needed user mail.

type ListOption added in v1.0.14

type ListOption func(*listOptions)

func WithAscending added in v1.0.14

func WithAscending(asc bool) ListOption

WithAscending lists messages by ascending order.

func WithLimit added in v1.0.14

func WithLimit(limit int) ListOption

WithLimit limits the number of list messages results.

func WithSeek added in v1.0.14

func WithSeek(id string) ListOption

WithSeek starts listing from the given ID.

func WithStatus added in v1.0.14

func WithStatus(s Status) ListOption

WithStatus filters messages by read status. Note: Only applies to inbox messages.

type Message added in v1.0.14

type Message struct {
	ID        string        `json:"_id"`
	From      thread.PubKey `json:"from"`
	To        thread.PubKey `json:"to"`
	Body      []byte        `json:"body"`
	Signature []byte        `json:"signature"`
	CreatedAt time.Time     `json:"created_at"`
	ReadAt    time.Time     `json:"read_at,omitempty"`
}

Message is the client side representation of a mailbox message. Signature corresponds to the encrypted body. Use message.Open to get the plaintext body.

func (Message) IsRead added in v1.0.14

func (m Message) IsRead() bool

IsRead returns whether or not the message has been read.

func (Message) Open added in v1.0.14

func (m Message) Open(ctx context.Context, id thread.Identity) ([]byte, error)

Open decrypts the message body with identity.

func (Message) UnmarshalInstance added in v1.0.14

func (m Message) UnmarshalInstance(data []byte) error

UnmarshalInstance unmarshals the message from its ThreadDB instance data. This will return an error if the message signature fails verification.

type Status added in v1.0.14

type Status int

Status indicates message read status.

const (
	// All includes read and unread messages.
	All Status = iota
	// Read is only read messages.
	Read
	// Unread is only unread messages.
	Unread
)

Jump to

Keyboard shortcuts

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