v1alpha2

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const Version = "v1alpha2"

Version is the latest supported version.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actions

type Actions struct {
	Archive  bool `yaml:"archive,omitempty"`
	Delete   bool `yaml:"delete,omitempty"`
	MarkRead bool `yaml:"markRead,omitempty"`
	Star     bool `yaml:"star,omitempty"`

	// MarkSpam can be used to disallow mails to be marked as spam.
	// This however is not allowed to be set to true by Gmail.
	MarkSpam      *bool `yaml:"markSpam,omitempty"`
	MarkImportant *bool `yaml:"markImportant,omitempty"`

	Category gmail.Category `yaml:"category,omitempty"`
	Labels   []string       `yaml:"labels,omitempty"`
}

Actions contains the actions to be applied to a set of emails.

func (Actions) Empty

func (a Actions) Empty() bool

Empty returns true if no actions are specified.

type Author

type Author v1alpha1.Author

Author represents the owner of the gmail account.

type Config

type Config struct {
	Version string        `yaml:"version"`
	Author  Author        `yaml:"author,omitempty"`
	Filters []NamedFilter `yaml:"filters,omitempty"`
	Rules   []Rule        `yaml:"rules"`
}

Config contains the yaml configuration of the Gmail filters.

func Import

func Import(cfg v1alpha1.Config) (Config, error)

Import converts a v1 config into a v2.

type FilterNode

type FilterNode struct {
	RefName string `yaml:"name,omitempty"`

	And []FilterNode `yaml:"and,omitempty"`
	Or  []FilterNode `yaml:"or,omitempty"`
	Not *FilterNode  `yaml:"not,omitempty"`

	From    string `yaml:"from,omitempty"`
	To      string `yaml:"to,omitempty"`
	Cc      string `yaml:"cc,omitempty"`
	Subject string `yaml:"subject,omitempty"`
	List    string `yaml:"list,omitempty"`
	Has     string `yaml:"has,omitempty"`
	Query   string `yaml:"query,omitempty"`
}

FilterNode represents a piece of a Gmail filter.

The definition is recursive, as filters can be composed together with the use of logical operators. For every filter node, only one operator can be specified. If you need to combine multiple queries together, combine the nodes with 'And', 'Or' and 'Not'.

func (FilterNode) Empty

func (f FilterNode) Empty() bool

Empty returns true if all the fields are empty.

func (FilterNode) NonEmptyFields

func (f FilterNode) NonEmptyFields() []string

NonEmptyFields returns the names of the fields with a value.

func (FilterNode) String

func (f FilterNode) String() string

type NamedFilter

type NamedFilter struct {
	Name  string     `yaml:"name"`
	Query FilterNode `yaml:"query"`
}

NamedFilter represents a filter with a name.

A named filter can be referenced by other named filters and by filters inside rules.

type Rule

type Rule struct {
	Filter  FilterNode `yaml:"filter"`
	Actions Actions    `yaml:"actions"`
}

Rule is the actual complete Gmail filter.

For every email, if the filter applies correctly, then the specified actions will be applied to it.

func (Rule) String

func (r Rule) String() string

Jump to

Keyboard shortcuts

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