Skip to content

Instantly share code, notes, and snippets.

@yiding
Created June 25, 2014 00:17
Show Gist options
  • Select an option

  • Save yiding/0ac7d4eddb07bd914090 to your computer and use it in GitHub Desktop.

Select an option

Save yiding/0ac7d4eddb07bd914090 to your computer and use it in GitHub Desktop.

Revisions

  1. Yiding Jia created this gist Jun 25, 2014.
    10 changes: 10 additions & 0 deletions imapfilter_phabricator.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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