Hi Micah, Something like the following could work:
spam = thread.labels.member? :spam what = spam ? 'spam' : 'ham' source_uri = "maildir:///tmp/mistakes" source = SourceManager.source_for(source_uri) or fail "source not found" thread.each do |m,a,b| next if !m or m == :fake_root info "marking message #{m.id} as #{what}" source.store_message m.date, m.from.email do |f| m.each_raw_message_line { |l| f.puts l } end end This code assumes a maildir (/tmp/mistakes) and that you've added it as a sup "source" with "sup-add -u maildir:///tmp/mistakes". When you mark a thread as spam/ham, it will store the messages into that maildir. One problem with the above code is that it does store the entire thread, so if only one message was miscategorized you'll end up confusing your spam filter. Depending on your exact mail setup you can probably do something smarter here. Excerpts from Micah Anderson's message of Tue Nov 10 23:08:22 -0500 2009: > There has to be some way to have sup actually move a message, isn't > there? Sup really doesn't like it when messages are deleted from a source. Best to just keep it a copy. For other sup developers: it shouldn't take this much hook code to do this. I suggest renaming Source#store_message to Source#store_raw. A new Source#store_message should take a Message as the first argument and let the mbox From header address and date be optional with reasonable defaults. We should also have a Thread#each_message which ignores any result of Thread#each that isn't a Message. These two changes would make the hook above a lot less magical. What other API changes could we do to make writing hooks easier? _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk