backend

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const InternalIDHeaderLength = 52

InternalIDHeaderLength is the expected length of the full header entry, excluding the new line character.

View Source
const InternalIDHeaderLengthWithNewLine = InternalIDHeaderLength + 2

InternalIDHeaderLengthWithNewLine is the same as InternalIDHeaderLength, but includes the \r\n character.

View Source
const InternalIDKey = `X-PM-GOMSRV-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

View Source
var (
	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")
	ErrSessionIsNotSelected = errors.New("session is not selected")
	ErrNotImplemented       = errors.New("not implemented")
)

Functions

func AsClose

func AsClose(parent context.Context) context.Context

AsClose marks this context as handling a CLOSE command. This modifies some backend behaviour (such as not returning EXPUNGE responses).

func AsSilent

func AsSilent(parent context.Context) context.Context

AsSilent marks this context as handling a silent STORE command. This modifies some backend behaviour (such as not returning EXPUNGE responses).

func AsUID

func AsUID(parent context.Context) context.Context

AsUID marks this context as handling a UID command. This modifies some backend behaviour (such as returning UID within FETCH responses).

Types

type Backend

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

func New

func New(dir string) *Backend

func (*Backend) AddUser

func (b *Backend) AddUser(userID, username, password string, conn connector.Connector, store store.Store, client *ent.Client) error

func (*Backend) Close

func (b *Backend) Close(ctx context.Context) error

func (*Backend) GetState

func (b *Backend) GetState(username, password string) (*State, error)

func (*Backend) SetDelimiter

func (b *Backend) SetDelimiter(delim string)

type Mailbox

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

func (*Mailbox) Append

func (m *Mailbox) Append(ctx context.Context, literal []byte, flags imap.FlagSet, date time.Time) (int, error)

func (*Mailbox) Attributes

func (m *Mailbox) Attributes(ctx context.Context) (imap.FlagSet, error)

func (*Mailbox) Close

func (m *Mailbox) Close(ctx context.Context) error

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) Count

func (m *Mailbox) Count() int

func (*Mailbox) Expunge

func (m *Mailbox) Expunge(ctx context.Context, seq *proto.SequenceSet) error

func (*Mailbox) ExpungeIssued

func (m *Mailbox) ExpungeIssued() bool

func (*Mailbox) Fetch

func (m *Mailbox) Fetch(ctx context.Context, seq *proto.SequenceSet, attributes []*proto.FetchAttribute, ch chan response.Response) error

func (*Mailbox) Flags

func (m *Mailbox) Flags(ctx context.Context) (imap.FlagSet, error)

func (*Mailbox) Flush

func (m *Mailbox) Flush(ctx context.Context, permitExpunge bool) ([]response.Response, error)

func (*Mailbox) GetMessagesWithFlag

func (m *Mailbox) GetMessagesWithFlag(flag string) []int

func (*Mailbox) GetMessagesWithoutFlag

func (m *Mailbox) GetMessagesWithoutFlag(flag string) []int

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) Name

func (m *Mailbox) Name() string

func (*Mailbox) PermanentFlags

func (m *Mailbox) PermanentFlags(ctx context.Context) (imap.FlagSet, error)

func (*Mailbox) ReadOnly

func (m *Mailbox) ReadOnly() bool

func (*Mailbox) Search

func (m *Mailbox) Search(ctx context.Context, keys []*proto.SearchKey) ([]int, error)

func (*Mailbox) Selected

func (m *Mailbox) Selected() bool

func (*Mailbox) Store

func (m *Mailbox) Store(ctx context.Context, seq *proto.SequenceSet, operation proto.Operation, flags imap.FlagSet) error

func (*Mailbox) Subscribed

func (m *Mailbox) Subscribed() bool

func (*Mailbox) UIDNext

func (m *Mailbox) UIDNext() int

func (*Mailbox) UIDValidity

func (m *Mailbox) UIDValidity() int

type Match

type Match struct {
	Name      string
	Delimiter string
	Atts      imap.FlagSet
}

type State

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

TODO(REFACTOR): Decide on the best way to pass around user/state/snap/pool objects! Currently quite gross...

func (*State) Close

func (state *State) Close(ctx context.Context) error

func (*State) Create

func (state *State) Create(ctx context.Context, name string) error

func (*State) Delete

func (state *State) Delete(ctx context.Context, name string) error

func (*State) Examine

func (state *State) Examine(ctx context.Context, name string, fn func(*Mailbox) error) error

func (*State) Idle

func (state *State) Idle(ctx context.Context, fn func([]response.Response, chan response.Response) error) error

func (*State) IsSelected

func (state *State) IsSelected() bool

func (*State) List

func (state *State) List(ctx context.Context, ref, pattern string, subscribed bool, fn func(map[string]Match) error) error

func (*State) Mailbox

func (state *State) Mailbox(ctx context.Context, name string, fn func(*Mailbox) error) error

func (*State) Rename

func (state *State) Rename(ctx context.Context, oldName, newName string) error

func (*State) Select

func (state *State) Select(ctx context.Context, name string, fn func(*Mailbox) error) error

func (*State) Selected

func (state *State) Selected(ctx context.Context, fn func(*Mailbox) error) error

func (*State) Subscribe

func (state *State) Subscribe(ctx context.Context, name string) error

func (*State) Unsubscribe

func (state *State) Unsubscribe(ctx context.Context, name string) error

func (*State) UserID

func (state *State) UserID() string

Jump to

Keyboard shortcuts

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