mess

package module
v0.0.0-...-b7ec3a6 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMessages = errors.New("No messages matched")

Functions

This section is empty.

Types

type Mailbox

type Mailbox interface {
	backend.Mailbox
	Conn() backend.Conn
}

type MailboxHandle

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

func (*MailboxHandle) Close

func (handle *MailboxHandle) Close() error

func (*MailboxHandle) FlagsChanged

func (handle *MailboxHandle) FlagsChanged(uid uint32, newFlags []string, silent bool)

FlagsChanged performans all necessary update dispatching actions on flags change.

newFlags should not include \Recent, silent should be set if UpdateMessagesFlags was called with it set.

func (*MailboxHandle) Idle

func (handle *MailboxHandle) Idle(done <-chan struct{})

func (*MailboxHandle) IsRecent

func (handle *MailboxHandle) IsRecent(uid uint32) bool

IsRecent indicates whether the message should be considered to have \Recent flag for this connection.

func (*MailboxHandle) MsgsCount

func (handle *MailboxHandle) MsgsCount() int

func (*MailboxHandle) Removed

func (handle *MailboxHandle) Removed(uid uint32)

Removed performs all necessary update dispatching actions for a specified removed message.

func (*MailboxHandle) RemovedSet

func (handle *MailboxHandle) RemovedSet(seq imap.SeqSet)

func (*MailboxHandle) ResolveCriteria

func (handle *MailboxHandle) ResolveCriteria(criteria *imap.SearchCriteria)

ResolveCriteria converts all SeqNum rules into corresponding Uid rules. Argument is modified directly.

func (*MailboxHandle) ResolveSeq

func (handle *MailboxHandle) ResolveSeq(uid bool, set *imap.SeqSet) (*imap.SeqSet, error)

ResolveSeq converts the passed UIDs or sequence numbers set into UIDs set that is appropriate for mailbox operations in this connection.

If resolution algorithm results in an empty set, ErrNoMessages is returned. Resulting set *may* include UIDs that were expunged in other connections, backend should ignore these as specified in RFC 3501.

func (*MailboxHandle) Sync

func (handle *MailboxHandle) Sync(expunge bool)

Sync sends all updates pending for this connection. This method should be called after each mailbox operation to ensure client sees changes as early as possible.

expunge should be set to true if EXPUNGE updates should be sent. IT SHOULD NOT BE SET WHILE EXECUTING A COMMAND USING SEQUENCE NUMBERS (except for COPY).

func (*MailboxHandle) UidAsSeq

func (handle *MailboxHandle) UidAsSeq(uid uint32) (uint32, bool)

type Manager

type Manager struct {
	ExternalSubscribe   func(key interface{})
	ExternalUnsubscribe func(key interface{})
	// contains filtered or unexported fields
}

func NewManager

func NewManager() *Manager

func (*Manager) ExternalUpdate

func (m *Manager) ExternalUpdate(upd Update)

ExternalUpdate deserializes externally received update and dispatches it internal.

func (*Manager) Mailbox

func (m *Manager) Mailbox(key interface{}, mbox Mailbox, uids []uint32, recents *imap.SeqSet) (*MailboxHandle, error)

Mailbox initializes a new message handle for the mailbox.

key should be a server-global unique identifier for the mailbox. uids should contain the list of all message UIDs existing in the mailbox.

recents should contain the list of message UIDs with persistent \Recent flag. Note that persistent \Recent should be unset once passed to Mailbox(). In particular, two subsequent calls should not receive the same value.

func (*Manager) MailboxDestroyed

func (m *Manager) MailboxDestroyed(key interface{})

MailboxDestroyed should be called when the specified key is no longer valid for the mailbox e.g. because it was renamed or deleted.

The appropriate place to call the method from is DeleteMailbox - MailboxDestroyed should be called for all removed mailboxes - and RenameMailbox where it should be called for _both_ source and target mailbox.

In all cases it is better to call MailboxDestroyed _after_ physically deleting the mailbox.

func (*Manager) ManagementHandle

func (m *Manager) ManagementHandle(key interface{}, uids []uint32, recents *imap.SeqSet) *MailboxHandle

ManagementHandle initializes a new message handle for the mailbox that is opened without an active connection, e.g. from an administrative UI or CLI utility.

Such handle never sends updates to mbox.Conn(), only to SetExternalSink if set. \Recent flag for new messages will never be shown to such connections and it will receive no updates for mailbox changes anyway (Idle, Sync are no-op).

func (*Manager) NewMessage

func (m *Manager) NewMessage(key interface{}, uid uint32) (storeRecent bool)

func (*Manager) NewMessages

func (m *Manager) NewMessages(key interface{}, uid imap.SeqSet) (storeRecent bool)

NewMessages performs necessary updates dispatching when new messages are added to the mailbox.

Return value indicates whether backend should store a persistent \Recent flag in DB for further retrieval (see Mailbox)

func (*Manager) SetExternalSink

func (m *Manager) SetExternalSink(upds chan<- Update)

SetExternalSink sets the channel where all updates generated by this Manager will be serialized.

Calling this multiple times will replace previosuly set channel. Call with nil to disable serialization.

It is not safe to call SetExternalSink concurrently with other operations.

type Update

type Update struct {
	Type     UpdateType
	Key      interface{}
	SeqSet   string   `json:",omitempty"`
	NewFlags []string `json:",omitempty"`
}

type UpdateType

type UpdateType int
const (
	UpdNewMessage UpdateType = iota
	UpdFlags
	UpdRemoved
	UpdMboxDestroyed
)

Directories

Path Synopsis
A memory backend.
A memory backend.

Jump to

Keyboard shortcuts

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