-
Notifications
You must be signed in to change notification settings - Fork 73
/
example.jsonnet
78 lines (74 loc) · 1.79 KB
/
example.jsonnet
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
// Import the standard library
local lib = import 'gmailctl.libsonnet';
// Some useful variables on top
local me = 'pippo@gmail.com';
local spam = {
or: [
{ from: 'spammer@spam.com' },
{ subject: 'foo bar baz' },
{ subject: 'I want to spam you' },
{ has: 'buy this' },
{ has: 'buy that' },
],
};
// The actual configuration
{
// Mandatory header
version: 'v1alpha3',
author: {
name: 'Pippo Pluto',
email: me,
},
// The list of Gmail filter rules.
rules: [
{
filter: {
from: 'myalarm@myalarm.com',
},
actions: {
markImportant: true,
labels: ['alarm'],
},
},
{
filter: spam,
actions: {
delete: true,
},
},
]
// Chained filters. These are applied in order: the first that
// matches stops the evaluation of the following ones.
//
// For example, if an email is directed to me and is coming from
// the list 'foobar@list.com', following the chain, it will be
// marked as important, but the 'mylist' label will _not_ be added.
+ lib.chainFilters([
{
filter: {
to: me,
},
actions: {
markImportant: true,
},
},
// else if...
{
filter: {
cc: me,
},
actions: {
archive: true,
},
},
// else if...
{
filter: {
list: 'foobar@list.com',
},
actions: {
labels: ['mylist'],
},
},
]),
}