query

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SortAny is the default Sorting and sorts with an undefined / unpredictable behavior.
	SortAny = Sorting(iota)
	// SortSendTime sorts mails by their send time.
	SortSendTime
	// SortSubject sorts mails by their subject.
	SortSubject
)
View Source
const (
	// SortAsc sorts in ascending order.
	SortAsc = SortDirection(iota)
	// SortDesc sorts in descending order.
	SortDesc
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AttachmentFilter

type AttachmentFilter struct {
	Filenames    []string
	ContentTypes []string
	Contents     [][]byte
	Size         AttachmentSizeFilter
}

AttachmentFilter is the query filter for attachments.

type AttachmentSizeFilter

type AttachmentSizeFilter struct {
	Exact  []int
	Ranges [][2]int
}

AttachmentSizeFilter is the query filter for attachment file sizes.

type Option

type Option func(*Query)

Option is a Query option.

func AttachmentContent

func AttachmentContent(content ...[]byte) Option

AttachmentContent returns an Option that adds an attachment filter to a Query. It filters attachments by their actual file contents.

func AttachmentContentType

func AttachmentContentType(cts ...string) Option

AttachmentContentType returns an Option that adds an attachment filter to a Query. It filters attachments by their MIME `Content-Type`.

func AttachmentFilename

func AttachmentFilename(names ...string) Option

AttachmentFilename returns an Option that adds an attachment filter to a Query. It filters attachments by their filename.

func AttachmentSize

func AttachmentSize(sizes ...int) Option

AttachmentSize returns an Option that add an attachment filter to a Query. It filters attachments by their file size.

func AttachmentSizeRange

func AttachmentSizeRange(min, max int) Option

AttachmentSizeRange returns an Option that adds an attachment filter to a Query. It filters attachments by their file size, where the attachment's file size must be in the inclusive range (min, max).

func BCC

func BCC(addr ...mail.Address) Option

BCC returns an Option that adds a `Bcc` filter to a Query.

func CC

func CC(addr ...mail.Address) Option

CC returns an Option that adds a `Cc` filter to a Query.

func From

func From(addr ...mail.Address) Option

From returns an Option that adds a `From` filter to a Query.

func Input added in v0.16.0

func Input(input string) Option

Input returns an Option that sets the search input for a Query.

func Paginate

func Paginate(page, perPage int) Option

Paginate returns an Option that configures the Pagination of a Query.

func Recipient

func Recipient(rcpts ...mail.Address) Option

Recipient returns an Option that adds a `Recipient` filter to a Query.

func SentAfter

func SentAfter(t ...time.Time) Option

SentAfter returns an Option that filters mails by their send time. The send time of a mail must be after any of t.

func SentAt

func SentAt(t ...time.Time) Option

SentAt returns an Option that filters mails by their send time. The send time of a mail must be one of t.

func SentBefore

func SentBefore(t ...time.Time) Option

SentBefore returns an Option that filters mails by their send time. The send time of a mail must be before any of t.

func SentBetween

func SentBetween(l, r time.Time) Option

SentBetween returns an Option that filters mails by their send time. The send time of a mail must be between (l, r).

func Sort

func Sort(by Sorting, dir SortDirection) Option

Sort returns an Option that configures the Sorting of a Query.

func Subject

func Subject(subjects ...string) Option

Subject returns an Option that adds a `Subject` filter to a Query.

func To

func To(addr ...mail.Address) Option

To returns an Option that adds a `To` filter to a Query.

type Pagination

type Pagination struct {
	Page    int
	PerPage int
}

Pagination is a pagination option.

type Query

type Query struct {
	From       []mail.Address
	To         []mail.Address
	CC         []mail.Address
	BCC        []mail.Address
	Recipients []mail.Address
	Subjects   []string
	// Texts         []string
	// HTML          []string
	// RFC           []string
	// SendErrors    []string
	SendTime      SendTimeFilter
	Attachment    AttachmentFilter
	Sorting       Sorting
	SortDirection SortDirection
	Pagination    Pagination
	Input         string
}

Query provides filters, sorting & pagination for querying mails.

func New

func New(opts ...Option) Query

New builds a Query using the provided opts.

type SendTimeFilter

type SendTimeFilter struct {
	Exact  []time.Time
	Before []time.Time
	After  []time.Time
}

SendTimeFilter is the query filter for the send date.

type SortDirection

type SortDirection int

SortDirection is a sorting direction.

type Sorting

type Sorting int

Sorting is a sorting.

func (Sorting) String

func (s Sorting) String() string

Jump to

Keyboard shortcuts

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