Skip to content

Instantly share code, notes, and snippets.

@yiding
Created June 25, 2014 00:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yiding/0ac7d4eddb07bd914090 to your computer and use it in GitHub Desktop.
Save yiding/0ac7d4eddb07bd914090 to your computer and use it in GitHub Desktop.
Imapfilter function to move all notifications related to phabricator notifications to a different folder
function pruneCommittedDiffs(mailbox, dest_mailbox)
diff_set = mailbox:contain_subject('[Differential]')
committed_diff_set = diff_set:contain_field('X-Phabricator-Mail-Tags', '<differential-committed>')
for _, message in ipairs(committed_diff_set) do
mmbox, uid = table.unpack(message)
rev_key = string.gsub(mmbox[uid]:fetch_field('In-Reply-To'), 'In%-Reply%-To: ', '')
all_diff_msgs = diff_set:contain_field('In-Reply-To', rev_key) + diff_set:contain_field('Message-ID', rev_key)
all_diff_msgs:move_messages(dest_mailbox)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment