Last active
September 22, 2016 21:49
-
-
Save Daviey/eb61c284b6d3bf6562763db2cb8a7351 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
// Get or create label | |
var label = GmailApp.getUserLabelByName("OSSP"); | |
if (label == null) { | |
var label = GmailApp.createLabel("OSSP"); | |
} | |
// lets go! | |
processInbox(label) | |
} | |
function processInbox(label) { | |
var threads = GmailApp.search("to:openstack-dev@lists.openstack.org newer_than:4h"); | |
for (var i = 0; i < threads.length; i++) { | |
var messages = threads[i].getMessages(); | |
for (var j = 0; j < messages.length; j++) { | |
var message = messages[j]; | |
processMessage(message, label); | |
} | |
} | |
} | |
function processMessage(message, label) { | |
var body = message.getRawContent(); | |
var searchtopic = "X-Topics.*(Security).*" | |
if (body.search(searchtopic) != -1) { | |
message.getThread().addLabel(label) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment