I get quite a bit of email notification from Pagure, the free (as in freedom!), Python-based git forge. I have and participate in several repos there. Pagure sends me email when there’s a new or updated issue, pull request, or commit to a repo I monitor.
Previously, all that email for me has gone into a “Pagure” folder. But Pagure offers a special header, X-pagure-project, which indicates the specific project that triggered the email. Unfortunately, Gmail’s filters notoriously lack the ability to parse arbitrary headers. This is actually a limitation of the Gmail API. Why there’s no getHeaders() call, I have no idea — but maybe it has something to do with worries about arbitrary content there.
Now, I could probably set up filters to look for mail From: email@example.com and then look in the subject line for [Project-name]. But this means I have to make a new filter for every project manually. YUCK!
Enter Google Apps Script
So I wrote my very first Google Apps Script (this script is licensed CC-BY-SA, version 3.0 or later at your option).
Here’s the link, which will stay up to date.
How to use the script
To use it, you first need to connect Google Apps Scripts to your Google Drive. (Use New –> More in Google Drive, if this isn’t already done.) Then save this as a new script in your Drive.
Adjust the parentlabel value if needed. Then set a timer trigger to run the processInbox function every 5 or 10 minutes.
Make sure to remove any existing filter for Pagure notification email, so that your script has a chance to run against notifications in your Inbox.
If you’ve never used Google Apps Scripts before, it’s easy to get started. I’m living proof, since I’m not much of a developer. Here’s a quick start from Google that will help.
Source From: fedoraplanet.org.
Original article title: Paul W. Frields: Better Pagure email filters for Gmail.
This full article can be read at: Paul W. Frields: Better Pagure email filters for Gmail.