mess

package module
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type MailboxHandle

type MailboxHandle[MailboxKey comparable] struct {
	// contains filtered or unexported fields
}

func (*MailboxHandle[MailboxKey]) Close

func (handle *MailboxHandle[MailboxKey]) Close() error

func (*MailboxHandle[MailboxKey]) FlagsChanged

func (handle *MailboxHandle[MailboxKey]) FlagsChanged(uid imap.UID, newFlags []imap.Flag, silent bool)

FlagsChanged performs 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[MailboxKey]) Idle

func (handle *MailboxHandle[MailboxKey]) Idle(to *imapserver.UpdateWriter, done <-chan struct{}) error

func (*MailboxHandle[MailboxKey]) IsRecent

func (handle *MailboxHandle[MailboxKey]) IsRecent(uid imap.UID) bool

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

func (*MailboxHandle[MailboxKey]) MsgsCount

func (handle *MailboxHandle[MailboxKey]) MsgsCount() int

func (*MailboxHandle[MailboxKey]) Removed

func (handle *MailboxHandle[MailboxKey]) Removed(uid imap.UID)

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

func (*MailboxHandle[MailboxKey]) RemovedSet

func (handle *MailboxHandle[MailboxKey]) RemovedSet(seq imap.UIDSet)

func (*MailboxHandle[MailboxKey]) ResolveCriteria

func (handle *MailboxHandle[MailboxKey]) ResolveCriteria(criteria *imap.SearchCriteria)

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

func (*MailboxHandle[MailboxKey]) ResolveSeq

func (handle *MailboxHandle[MailboxKey]) ResolveSeq(set imap.SeqSet) (imap.UIDSet, 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[MailboxKey]) ResolveUID

func (handle *MailboxHandle[MailboxKey]) ResolveUID(set imap.UIDSet) (imap.UIDSet, error)

func (*MailboxHandle[MailboxKey]) Sync

func (handle *MailboxHandle[MailboxKey]) Sync(to *imapserver.UpdateWriter, expunge bool) error

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[MailboxKey]) UidAsSeq

func (handle *MailboxHandle[MailboxKey]) UidAsSeq(uid imap.UID) (uint32, bool)

type Manager

type Manager[MailboxKey comparable] struct {
	ExternalSubscribe   func(key MailboxKey)
	ExternalUnsubscribe func(key MailboxKey)
	// contains filtered or unexported fields
}

func NewManager

func NewManager[MailboxKey comparable]() *Manager[MailboxKey]

func (*Manager[MailboxKey]) ExternalUpdate

func (m *Manager[MailboxKey]) ExternalUpdate(upd Update[MailboxKey])

ExternalUpdate deserializes externally received update and dispatches it internal.

func (*Manager[MailboxKey]) Mailbox

func (m *Manager[MailboxKey]) Mailbox(key MailboxKey, uids []imap.UID, recents imap.UIDSet) (*MailboxHandle[MailboxKey], 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[MailboxKey]) MailboxDestroyed

func (m *Manager[MailboxKey]) MailboxDestroyed(key MailboxKey)

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[MailboxKey]) ManagementHandle

func (m *Manager[MailboxKey]) ManagementHandle(key MailboxKey, uids []imap.UID, recents imap.UIDSet) *MailboxHandle[MailboxKey]

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[MailboxKey]) NewMessage

func (m *Manager[MailboxKey]) NewMessage(key MailboxKey, uid imap.UID) (storeRecent bool)

func (*Manager[MailboxKey]) NewMessages

func (m *Manager[MailboxKey]) NewMessages(key MailboxKey, uid imap.UIDSet) (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[MailboxKey]) SetExternalSink

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

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[MailboxKey comparable] struct {
	Type     UpdateType
	Key      MailboxKey
	SeqSet   imap.UIDSet `json:",omitempty"`
	NewFlags []imap.Flag `json:",omitempty"`
}

type UpdateType

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

Jump to

Keyboard shortcuts

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