Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type filter struct {
ArchiveUnlessToMe bool
Label string
ForwardTo string
Star bool
}

func (f filter) toGmailFilters(labels *labelMap) ([]gmail.Filter, error) {
Expand Down Expand Up @@ -72,6 +73,10 @@ func (f filter) toGmailFilters(labels *labelMap) ([]gmail.Filter, error) {
action.AddLabelIds = append(action.AddLabelIds, "TRASH")
}

if f.Star {
action.AddLabelIds = append(action.AddLabelIds, "STARRED")
}

if len(f.ForwardTo) > 0 {
action.Forward = f.ForwardTo
}
Expand Down
17 changes: 17 additions & 0 deletions filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,23 @@ func TestFilterToGmailFilters(t *testing.T) {
},
},
},
"starred": {
orig: filter{
QueryOr: []string{"to:[email protected]", "to:[email protected]"},
Star: true,
},
expected: []gmail.Filter{
{
Action: &gmail.FilterAction{
AddLabelIds: []string{"STARRED"},
RemoveLabelIds: []string{},
},
Criteria: &gmail.FilterCriteria{
Query: "to:[email protected] OR to:[email protected]",
},
},
},
},
}

labels := &labelMap{
Expand Down