Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] threading and blackberrys
@ 2011-03-06 22:54 Hamish
  0 siblings, 0 replies; only message in thread
From: Hamish @ 2011-03-06 22:54 UTC (permalink / raw)
  To: sup-talk

Hello all

Where I work some people use Blackberries, and they don't add an
In-Reply-To header to email, so I do quite a bit of manual re-threading
using the '#' key. I'd like to not have to do it so much, but I don't
want to just thread all mail by subject, as the blackberry messages are
not /so/ frequent. So I've put the below in my before-add-message.rb
hook that others might find useful.

The code:

* only runs if the message is from a blackberry and the subject
  indicates it is a reply.
* looks for the most recent message that matches the subject, and adds a
  ref to that message, so they should then be in the same thead.

Any feedback or improvements appreciated.

Hamish


subj = message.subj.downcase

# if from a blackberry and is a reply, then try to find a matching thread
if message.id.downcase.include?('blackberry') && Message.subj_is_reply?(subj)
  thread_subj = Message.normalize_subj subj
  query = Index.parse_query "subject:\"#{thread_subj}\""
  # the query returns newest match first
  first_id = Index.each_id(query) { |id| break id }
  message.add_ref(first_id) unless first_id.nil?
end
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-03-06 23:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-06 22:54 [sup-talk] threading and blackberrys Hamish

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox