Last active
August 29, 2015 14:24
-
-
Save theist/606e8dbaa2d887f2afe2 to your computer and use it in GitHub Desktop.
quick script for erase any redmine mail whose ticket id matches another containing also the word "Cerrada" or "Resuelta"
This file contains hidden or 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
| require 'gmail' | |
| require 'rfc2047' | |
| to_remove = [] | |
| gmail = Gmail.connect(username,password) | |
| rmine = gmail.inbox.find(:from => redmine_address) | |
| puts "processing #{rmine.count} messages" | |
| rmine.each do |mail| | |
| subj = Rfc2047.decode(mail.subject) | |
| if (subj =~ /\[[^#]+#([0-9]+)\]/) | |
| tid = $1 | |
| puts subj | |
| if (subj =~ /(Resuelta)|(Cerrada)/) | |
| to_remove.push(tid) | |
| puts tid + " will be removed" | |
| end | |
| end | |
| end | |
| rmine.each do |mail| | |
| subj = Rfc2047.decode(mail.subject) | |
| if (subj =~ /\[[^#]+#([0-9]+)\]/) | |
| tid = $1 | |
| if to_remove.include?(tid) | |
| puts "erasing " + subj | |
| mail.delete! | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment