Contents

refreshMailbox#

Download new messages from a mailbox service: messages are fetched in batches, decrypted with the mailbox’s private encryption key, stored in the wallet’s local database and deleted on the mailbox service.

Request:

The request arguments are a MailboxConfiguration object for the mailbox to refresh.

Response:

On success, the result is a MailboxMessageRecordsResponse object with the newly downloaded messages.

Side effects:

Downloads new messages from the mailbox service over the network, stores them in the wallet’s local database and deletes them on the service. A mailbox-message-added notification is emitted for each stored message.

Expected errors:

The caller can handle the following errors inline: WALLET_MAILBOX_UNAVAILABLE, WALLET_RECEIVED_MALFORMED_RESPONSE.

Details:

The configuration of the mailbox service (message size and response limit) is fetched before the first batch. Each downloaded message is stored like in addMailboxMessage. Messages that cannot be decrypted are skipped. At most 100 batches are fetched in one call. WALLET_RECEIVED_MALFORMED_RESPONSE indicates that the mailbox service returned an invalid response (invalid response limit, or a message list whose size is not a multiple of the advertised message size).

interface MailboxMessageRecordsResponse {
  // Newly downloaded messages.
  messages: MailboxMessageRecord[];
}