The QueryOr is a bit too complex to export, so everything is exported as a Query. Take for example the (from:(-me) {filename:vcs filename:ics} has:attachment) OR (subject:(\"invitation\" OR \"accepted\" OR \"tentatively accepted\" OR \"rejected\" OR \"updated\" OR \"canceled event\" OR \"declined\") when where calendar who organizer) query. There are multiple OR statements within another OR which should not be divided. So a simple strings.split won't do the trick, but more complex logic is needed to determine whether or not this should be split, or be kept as a single statement. It's doable, but given that it's almost new year's eve I didn't really have the time nor the desire to do so today I went for the quick solution. Since the QueryOr parameter is syntactic sugar for a regular Query this shouldn't cause any problems.
Every property of the Filter struct is exported, so the exported file is larger than the sample input file. Also, the property names start with an uppercase, simply because I can't seem to configure this in the toml encoder configuration. Doesn't cause a problem though.
There's only one check for duplicate filters when exporting, and that's for the ArchiveUnlessToMe and it simply does it on the query string. As input, the ArchiveUnlessToMe creates two filters, but the export should convert this into one filter, or you will get a duplicate filter error when trying to import an exported file. There might be other scenario's were duplicate filters are created to achieve a single thing, but this should be enough to cover the current import implementation.
This pull request adds rudimentary support for exporting the current set of Gmail filters, so you are not forced to start from a blank file.
Basic usage is the same as importing the filters, with the addition of the
-e
flag.A few things to note:
QueryOr
is a bit too complex to export, so everything is exported as aQuery
. Take for example the(from:(-me) {filename:vcs filename:ics} has:attachment) OR (subject:(\"invitation\" OR \"accepted\" OR \"tentatively accepted\" OR \"rejected\" OR \"updated\" OR \"canceled event\" OR \"declined\") when where calendar who organizer)
query. There are multipleOR
statements within anotherOR
which should not be divided. So a simplestrings.split
won't do the trick, but more complex logic is needed to determine whether or not this should be split, or be kept as a single statement. It's doable, but given that it's almost new year's eve I didn't really have the time nor the desire to do so today I went for the quick solution. Since theQueryOr
parameter is syntactic sugar for a regularQuery
this shouldn't cause any problems.Filter
struct is exported, so the exported file is larger than the sample input file. Also, the property names start with an uppercase, simply because I can't seem to configure this in the toml encoder configuration. Doesn't cause a problem though.ArchiveUnlessToMe
and it simply does it on the query string. As input, theArchiveUnlessToMe
creates two filters, but the export should convert this into one filter, or you will get a duplicate filter error when trying to import an exported file. There might be other scenario's were duplicate filters are created to achieve a single thing, but this should be enough to cover the current import implementation.