4 ms·
I made something like this a while back for myself, and it worked all right, but I ended up never even using it myself. The main problems I had were: - You end
by mehrdadn 7y ago
I made something like this a while back for myself, and it worked all right, but I ended up never even using it myself. The main problems I had were:
- You end up with multiple sources of truth for what's happening to your email. And/or you won't be able to easily edit your filters from multiple machines.
- Either the source code or the generated code ends up being hard to read.
- There's imperative (and sometimes counterintuitive) behavior in Gmail regarding labels, and that can interfere with declarative reasoning.
- Filters have a size limit! So you might need to take that into account if you have complicated filters.
- saulrh 7y ago`gmailctl` resolves a few of these, actually. The big one is that there's a command to diff your config file with what's in gmail, so you can capture any accidental changes that happen in gmail-land. This also helps with version-controlling your configuration, since it shows you when you just forgot to upload your config. The imperative behavior and filter size limits are still annoying, granted. You can deal with it by staging through multiple labels, but it's not great.
- mehrdadn 7y agoOh cool! Version control is useful. I might give it a shot sometime. I didn't have anything of the sort. If you're curious, the tool I came up with had a DSL like this: $excom = from:example.com $exorg = from:(example.org OR example.net) if ($excom AND $exorg) AND -(to:me OR in:spam) archive if cc:person label "Person" end end and it'd auto-translate to this: <?xml version='1.0' encoding='UTF-8'?> <feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'> <entry> <category term='filter'></category> <apps:property name='hasTheWord' value='(from:example.com from:{example.org example.net}) -{to:me in:spam}'/> <apps:property name='shouldArchive' value='true'/> </entry> <entry> <category term='filter'></category> <apps:property name='hasTheWord' value='(from:example.com from:{example.org example.net}) -{to:me in:spam} cc:person'/> <apps:property name='label' value='Person'/> </entry> </feed> which it would translate back to this: if (from:example.com from:{example.org example.net}) -{to:me in:spam} archive end if (from:example.com from:{example.org example.net}) -{to:me in:spam} cc:person label "Person" end It didn't treat the filter as a blob (it actually parsed it and removed quotes etc. if appropriate) but it also didn't really change the underlying language either. But it had variable and did let you nest conditions which made it easier to write some things. (Or so I hoped. In the end I didn't feel it was worth it...)
- tbodt 7y agoAnother advantage of gmailctl is it uploads the filters using the API, so you don't have open Gmail settings and manually import an XML file.
- inakarmacoma 7y agoYou can technically get around the filter limit by switching from filters to Appsv Script. Setup a staging inbox, then run the query and action rules against that stagig area every 1 to 5 minutes.
- mehrdadn 7y agoI've considered that for a long time, but the trouble is it's not as robust, not to mention there's also a script time limit which I would hit as a result of having other scripts...