Documentation ¶
Index ¶
- Constants
- Variables
- func AsClose(parent context.Context) context.Context
- func AsSilent(parent context.Context) context.Context
- func AsUID(parent context.Context) context.Context
- func DBAddMessageFlag(ctx context.Context, tx *ent.Tx, messageIDs []string, addFlag string) error
- func DBAddMessagesToMailbox(ctx context.Context, tx *ent.Tx, messageIDs []string, mboxID string) (map[string]int, error)
- func DBBumpMailboxUIDNext(ctx context.Context, tx *ent.Tx, mbox *ent.Mailbox, withCount ...int) error
- func DBClearRecentFlag(ctx context.Context, tx *ent.Tx, mboxID, messageID string) error
- func DBClearRecentFlags(ctx context.Context, tx *ent.Tx, mboxID string) error
- func DBCreateMailbox(ctx context.Context, tx *ent.Tx, mboxID, name string, ...) (*ent.Mailbox, error)
- func DBCreateMessages(ctx context.Context, tx *ent.Tx, reqs ...*DBCreateMessageReq) ([]*ent.Message, error)
- func DBDeleteMailbox(ctx context.Context, tx *ent.Tx, mboxID string) error
- func DBDeleteMessages(ctx context.Context, tx *ent.Tx, messageIDs ...string) error
- func DBGetAllMailboxes(ctx context.Context, client *ent.Client) ([]*ent.Mailbox, error)
- func DBGetMailboxByID(ctx context.Context, client *ent.Client, id string) (*ent.Mailbox, error)
- func DBGetMailboxByName(ctx context.Context, client *ent.Client, name string) (*ent.Mailbox, error)
- func DBGetMailboxMessage(ctx context.Context, client *ent.Client, mailboxID, messageID string) (*ent.UID, error)
- func DBGetMailboxMessageIDs(ctx context.Context, client *ent.Client, mailboxID string) ([]string, error)
- func DBGetMailboxMessages(ctx context.Context, mbox *ent.Mailbox) ([]*ent.UID, error)
- func DBGetMailboxMessagesForNewSnapshot(ctx context.Context, mbox *ent.Mailbox) ([]*ent.UID, error)
- func DBGetMailboxName(ctx context.Context, client *ent.Client, mboxID string) (string, error)
- func DBGetMailboxRecentCount(ctx context.Context, mbox *ent.Mailbox) (int, error)
- func DBGetMessage(ctx context.Context, client *ent.Client, messageID string) (*ent.Message, error)
- func DBGetMessageDeleted(ctx context.Context, client *ent.Client, mboxID string, messageIDs []string) (map[string]bool, error)
- func DBGetMessageFlags(ctx context.Context, client *ent.Client, messageIDs []string) (map[string]imap.FlagSet, error)
- func DBGetMessageID(ctx context.Context, client *ent.Client, internalID string) (string, error)
- func DBGetMessageIDsMarkedDeleted(ctx context.Context, tx *ent.Tx) ([]string, error)
- func DBGetMessageMailboxIDs(ctx context.Context, client *ent.Client, messageID string) ([]string, error)
- func DBGetMessageUIDs(ctx context.Context, client *ent.Client, mboxID string, messageIDs []string) (map[string]int, error)
- func DBGetMessages(ctx context.Context, client *ent.Client, messageIDs ...string) (map[string]*ent.Message, error)
- func DBGetUIDInterval(ctx context.Context, mbox *ent.Mailbox, begin, end int) ([]*ent.UID, error)
- func DBMailboxExistsWithID(ctx context.Context, client *ent.Client, mboxID string) (bool, error)
- func DBMailboxExistsWithName(ctx context.Context, client *ent.Client, name string) (bool, error)
- func DBMarkMessageAsDeleted(ctx context.Context, tx *ent.Tx, messageID string) error
- func DBMessageExists(ctx context.Context, client *ent.Client, messageID string) (bool, error)
- func DBRemoveMessageFlag(ctx context.Context, tx *ent.Tx, messageIDs []string, remFlag string) error
- func DBRemoveMessagesFromMailbox(ctx context.Context, tx *ent.Tx, messageIDs []string, mboxID string) error
- func DBRenameMailbox(ctx context.Context, tx *ent.Tx, mboxID, name string) error
- func DBSetDeletedFlag(ctx context.Context, tx *ent.Tx, mboxID string, messageIDs []string, ...) error
- func DBSetMessageFlags(ctx context.Context, tx *ent.Tx, messageIDs []string, setFlags imap.FlagSet) error
- func DBUpdateMailboxID(ctx context.Context, tx *ent.Tx, oldID, newID string) error
- func DBUpdateMessageID(ctx context.Context, tx *ent.Tx, oldID, newID string) error
- type Backend
- func (b *Backend) AddUser(ctx context.Context, userID string, conn connector.Connector, ...) error
- func (b *Backend) Close(ctx context.Context) error
- func (b *Backend) GetState(username, password string, sessionID int) (*State, error)
- func (b *Backend) NewUserID() string
- func (b *Backend) RemoveUser(ctx context.Context, userID string) error
- func (b *Backend) SetDelimiter(delim string)
- type DBCreateMessageReq
- type Mailbox
- func (m *Mailbox) Append(ctx context.Context, literal []byte, flags imap.FlagSet, date time.Time) (int, error)
- func (m *Mailbox) Attributes(ctx context.Context) (imap.FlagSet, error)
- func (m *Mailbox) Close(ctx context.Context) error
- func (m *Mailbox) Copy(ctx context.Context, seq *proto.SequenceSet, name string) (response.Item, error)
- func (m *Mailbox) Count() int
- func (m *Mailbox) Expunge(ctx context.Context, seq *proto.SequenceSet) error
- func (m *Mailbox) ExpungeIssued() bool
- func (m *Mailbox) Fetch(ctx context.Context, seq *proto.SequenceSet, ...) error
- func (m *Mailbox) Flags(ctx context.Context) (imap.FlagSet, error)
- func (m *Mailbox) Flush(ctx context.Context, permitExpunge bool) ([]response.Response, error)
- func (m *Mailbox) GetMessagesWithFlag(flag string) []int
- func (m *Mailbox) GetMessagesWithoutFlag(flag string) []int
- func (m *Mailbox) Move(ctx context.Context, seq *proto.SequenceSet, name string) (response.Item, error)
- func (m *Mailbox) Name() string
- func (m *Mailbox) PermanentFlags(ctx context.Context) (imap.FlagSet, error)
- func (m *Mailbox) ReadOnly() bool
- func (m *Mailbox) Search(ctx context.Context, keys []*proto.SearchKey, decoder *encoding.Decoder) ([]int, error)
- func (m *Mailbox) Selected() bool
- func (m *Mailbox) Store(ctx context.Context, seq *proto.SequenceSet, operation proto.Operation, ...) error
- func (m *Mailbox) Subscribed() bool
- func (m *Mailbox) UIDNext() int
- func (m *Mailbox) UIDValidity() int
- type Match
- type State
- func (state *State) Close(ctx context.Context) error
- func (state *State) Create(ctx context.Context, name string) error
- func (state *State) Delete(ctx context.Context, name string) error
- func (state *State) Done() <-chan struct{}
- func (state *State) Examine(ctx context.Context, name string, fn func(*Mailbox) error) error
- func (state *State) Idle(ctx context.Context, ...) error
- func (state *State) IsSelected() bool
- func (state *State) List(ctx context.Context, ref, pattern string, subscribed bool, ...) error
- func (state *State) Mailbox(ctx context.Context, name string, fn func(*Mailbox) error) error
- func (state *State) Rename(ctx context.Context, oldName, newName string) error
- func (state *State) Select(ctx context.Context, name string, fn func(*Mailbox) error) error
- func (state *State) Selected(ctx context.Context, fn func(*Mailbox) error) error
- func (state *State) SetConnMetadataKeyValue(key string, value any) error
- func (state *State) Subscribe(ctx context.Context, name string) error
- func (state *State) Unsubscribe(ctx context.Context, name string) error
- func (state *State) UserID() string
Constants ¶
const InternalIDHeaderLength = 51
InternalIDHeaderLength is the expected length of the full header entry, excluding the new line character.
const InternalIDHeaderLengthWithNewLine = InternalIDHeaderLength + 2
InternalIDHeaderLengthWithNewLine is the same as InternalIDHeaderLength, but includes the \r\n character.
const InternalIDKey = `X-PM-GLUON-ID`
InternalIDKey is the key of the header entry we add to messages in the mailserver system. This allows us to detect when clients try to create a duplicate of a message, which we treat instead as a copy.
Variables ¶
var ( ErrNoSuchUser = errors.New("no such user") ErrNoSuchSnapshot = errors.New("no such snapshot") ErrNoSuchMessage = errors.New("no such message") ErrNoSuchMailbox = errors.New("no such mailbox") ErrExistingMailbox = errors.New("a mailbox with that name already exists") ErrAlreadySubscribed = errors.New("already subscribed to this mailbox") ErrAlreadyUnsubscribed = errors.New("not subscribed to this mailbox") ErrSessionNotSelected = errors.New("session is not selected") ErrNotImplemented = errors.New("not implemented") )
Functions ¶
func AsClose ¶
AsClose marks this context as handling a CLOSE command. This modifies some backend behaviour (such as not returning EXPUNGE responses).
func AsSilent ¶
AsSilent marks this context as handling a silent STORE command. This modifies some backend behaviour (such as not returning EXPUNGE responses).
func AsUID ¶
AsUID marks this context as handling a UID command. This modifies some backend behaviour (such as returning UID within FETCH responses).
func DBAddMessageFlag ¶ added in v0.9.0
func DBAddMessagesToMailbox ¶ added in v0.9.0
func DBBumpMailboxUIDNext ¶ added in v0.9.0
func DBClearRecentFlag ¶ added in v0.9.0
func DBClearRecentFlags ¶ added in v0.9.0
func DBCreateMailbox ¶ added in v0.9.0
func DBCreateMessages ¶ added in v0.9.0
func DBDeleteMailbox ¶ added in v0.9.0
func DBDeleteMessages ¶ added in v0.9.0
func DBGetAllMailboxes ¶ added in v0.9.0
func DBGetMailboxByID ¶ added in v0.9.0
func DBGetMailboxByName ¶ added in v0.9.0
func DBGetMailboxMessage ¶ added in v0.9.0
func DBGetMailboxMessageIDs ¶ added in v0.9.0
func DBGetMailboxMessages ¶ added in v0.9.0
func DBGetMailboxMessagesForNewSnapshot ¶ added in v0.9.0
func DBGetMailboxName ¶ added in v0.9.0
func DBGetMailboxRecentCount ¶ added in v0.9.0
func DBGetMessage ¶ added in v0.9.0
func DBGetMessageDeleted ¶ added in v0.9.0
func DBGetMessageFlags ¶ added in v0.9.0
func DBGetMessageFlags(ctx context.Context, client *ent.Client, messageIDs []string) (map[string]imap.FlagSet, error)
DBGetMessageFlags returns the flags of the given messages. It does not include per-mailbox flags (\Deleted, \Recent)!
func DBGetMessageID ¶ added in v0.9.0
func DBGetMessageIDsMarkedDeleted ¶ added in v0.9.0
func DBGetMessageMailboxIDs ¶ added in v0.9.0
func DBGetMessageUIDs ¶ added in v0.9.0
func DBGetMessages ¶ added in v0.9.0
func DBGetUIDInterval ¶ added in v0.9.0
func DBMailboxExistsWithID ¶ added in v0.9.0
func DBMailboxExistsWithName ¶ added in v0.9.0
func DBMarkMessageAsDeleted ¶ added in v0.9.0
func DBMessageExists ¶ added in v0.9.0
func DBRemoveMessageFlag ¶ added in v0.9.0
func DBRemoveMessagesFromMailbox ¶ added in v0.9.0
func DBRenameMailbox ¶ added in v0.9.0
func DBSetDeletedFlag ¶ added in v0.9.0
func DBSetMessageFlags ¶ added in v0.9.0
func DBUpdateMailboxID ¶ added in v0.9.0
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
func (*Backend) RemoveUser ¶ added in v0.5.0
func (*Backend) SetDelimiter ¶
type DBCreateMessageReq ¶ added in v0.9.0
type DBCreateMessageReq struct {
// contains filtered or unexported fields
}
type Mailbox ¶
type Mailbox struct {
// contains filtered or unexported fields
}
func (*Mailbox) Attributes ¶
func (*Mailbox) Copy ¶
func (m *Mailbox) Copy(ctx context.Context, seq *proto.SequenceSet, name string) (response.Item, error)
Copy copies the messages represented by the given sequence set into the mailbox with the given name. If the context is a UID context, the sequence set refers to message UIDs. If no items are copied the response object will be nil.
func (*Mailbox) ExpungeIssued ¶
func (*Mailbox) Fetch ¶
func (m *Mailbox) Fetch(ctx context.Context, seq *proto.SequenceSet, attributes []*proto.FetchAttribute, ch chan response.Response) error
func (*Mailbox) GetMessagesWithFlag ¶
func (*Mailbox) GetMessagesWithoutFlag ¶
func (*Mailbox) Move ¶
func (m *Mailbox) Move(ctx context.Context, seq *proto.SequenceSet, name string) (response.Item, error)
Move moves the messages represented by the given sequence set into the mailbox with the given name. If the context is a UID context, the sequence set refers to message UIDs. If no items are moved the response object will be nil.
func (*Mailbox) PermanentFlags ¶
func (*Mailbox) Subscribed ¶
func (*Mailbox) UIDValidity ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
TODO(REFACTOR): Decide on the best way to pass around user/state/snap objects! Currently quite gross...