Subject: [sup-talk] [PATCH] Fix for before-add-message hook

From: [email-masked] (Marcus Williams)
Date: Tue, 06 Nov 2007 10:25:04 +0000

Hi -

Last one for now. This fixes the hook for filtering messages so that
messages you tag with spam/killed/deleted in the hook dont get
displayed by the inbox.

Just to confirm something: if you want to tag using one of these
labels you need to use the ruby symbol in the hook :spam, :killed and
:deleted

Eg:

message.add_label :spam if message.raw_header =~ /X-Spam-Flag: YES/

Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: before-add-message-hook
Type: application/octet-stream
Size: 1117 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071106/07ad0c18/attachment.obj

---

From: [email-masked] (William Morgan)
Date: Tue, 06 Nov 2007 17:56:31 -0800

> messages you tag with spam/killed/deleted in the hook dont get

And applied. Thanks for all your hard work, Marcus!

-- 
William <wmorgan-sup at masanjin.net>

---

From: [email-masked] (Marcus Williams)
Date: Wed, 07 Nov 2007 16:06:18 +0000

> And applied. Thanks for all your hard work, Marcus!

... Mmmm - I'm having a few problems with that is-relevant change.
Sometimes (I've just seen one now) I get a new message that doesnt
make it to the inbox. Whats odd is that it does appear if I pull in a
few more threads or somehow update the inbox buffer.

It might not be related to this change, but I'd not noticed it until
just now. I'll see if I can reproduce it somehow.

Marcus

---

From: [email-masked] (Marcus Williams)
Date: Wed, 07 Nov 2007 16:34:32 +0000

> just now. I'll see if I can reproduce it somehow.

Got it - in is_relevant you changed the patch to use "&&" instead of
"and" and I think this broke it because of the precedence of "&&"
makes it do

m.labels.include? (:inbox && ......)

whereas mine does

(m.labels.include? :inbox) and (......)

reverting back to "and" fixes it in my version.

Marcus

---

From: [email-masked] (William Morgan)
Date: Wed, 07 Nov 2007 09:35:11 -0800

> "and" and I think this broke it because of the precedence of "&&"

Good catch. Fixed in SVN. (Still refusing to use "and" though
:) )

---

From: [email-masked] (William Morgan)
Date: Wed, 07 Nov 2007 09:41:36 -0800

> Good catch. Fixed in SVN. (Still refusing to use "and" though

To be clear, idiomatic Ruby is to use and/or for short-cut exit checks
like "or return nil", and use && and || for all "normal" boolean
comparisons. I'm not just trying to be a jerk! But I did blindly make
that change your patch without thinking about what I was doing, so thank
you for catching that.

---

From: [email-masked] (Christopher Warrington)
Date: Wed, 07 Nov 2007 12:38:19 -0600

> Good catch. Fixed in SVN. (Still refusing to use "and" though

Thanks guys! This had been bugging me all day.

-- 
Christopher Warrington <chrisw at rice.edu>
Jones College