-
Notifications
You must be signed in to change notification settings - Fork 72
/
config.go
78 lines (67 loc) · 2.43 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package v1alpha1
import (
"github.com/mbrt/gmailctl/internal/engine/gmail"
)
// Version is the config format version supported by this package.
const Version = "v1alpha1"
// Config contains the yaml configuration of the Gmail filters.
type Config struct {
Version string `yaml:"version"`
Author Author `yaml:"author"`
Consts Consts `yaml:"consts,omitempty"`
Rules []Rule `yaml:"rules"`
}
// Consts maps names to a list of string values
type Consts map[string]ConstValue
// Author represents the owner of the gmail account.
type Author struct {
Name string `yaml:"name" json:"name"`
Email string `yaml:"email" json:"email"`
}
// ConstValue is a container for an array of string values.
type ConstValue struct {
Values []string `yaml:"values"`
}
// Rule is a filter with an associated action.
type Rule struct {
Filters Filters `yaml:"filters"`
Actions Actions `yaml:"actions"`
}
// Filters determine how to select emails.
//
// Two ways are possible: by directly specifying the constants in the match filters
// or by referring to constants specified by the global `consts` section on top of the
// config.
type Filters struct {
CompositeFilters `yaml:",inline"`
Consts CompositeFilters `yaml:"consts"`
Query string `yaml:"query"`
}
// CompositeFilters contains alternatively match or negation of matches.
//
// All the conditions are put in AND together.
type CompositeFilters struct {
MatchFilters `yaml:",inline"`
Not MatchFilters `yaml:"not"`
}
// MatchFilters contains a list of filters interpreted at a higher level.
//
// Every type of filter (e.g. Subject) is an array or requirements. They will be OR-ed
// together. If multiple types of filters are specified, they will be put in AND together.
type MatchFilters struct {
From []string `yaml:"from,omitempty"`
To []string `yaml:"to,omitempty"`
Cc []string `yaml:"cc,omitempty"`
Subject []string `yaml:"subject,omitempty"`
Has []string `yaml:"has,omitempty"`
List []string `yaml:"list,omitempty"`
}
// Actions contains the actions to be applied to a set of emails.
type Actions struct {
Archive bool `yaml:"archive,omitempty"`
Delete bool `yaml:"delete,omitempty"`
MarkImportant bool `yaml:"markImportant,omitempty"`
MarkRead bool `yaml:"markRead,omitempty"`
Category gmail.Category `yaml:"category,omitempty"`
Labels []string `yaml:"labels,omitempty"`
}