Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
* [sup-talk] More before-add hook issues
@ 2011-02-15 14:55 Philippe LeCavalier
  2011-02-16  9:31 ` Tero Tilus
  0 siblings, 1 reply; 3+ messages in thread
From: Philippe LeCavalier @ 2011-02-15 14:55 UTC (permalink / raw)
  To: sup-talk

Not certain what I did but the following used to work and now it doesn't. I have this:

1 #bit of spam control
2 if message.raw_header =~ /X-Spam-Flag: YES/
3  message.add_label :spam
4  log "Marking message #{message.id} as spam, subject is '#{message.subj}'"
5 end
6
7 addressfile = File.open("/home/plecavalier/.sup/hooks/label.lists","r")
8 if ! addressfile.grep(/#{message.list_address.email}/).empty?
9   message.add_label :lists
10 end

in before-add-message.rb. At the moment that is all I have in there.

And this:

cups@easysw.com
samba@lists.samba.org
rsync@lists.samba.org
offlineimap-project@lists.alioth.debian.org
bind-users@lists.isc.org

in ~/.sup/hooks/label.lists.

If I state this: {message.list_address.email}

I get this:
[Tue Feb 15 09:32:21 -0500 2011] hook: error running /home/plecavalier/.sup/hooks/before-add-message.rb: undefined method `email' for nil:NilClass
[Tue Feb 15 09:32:21 -0500 2011] hook: /home/plecavalier/.sup/hooks/before-add-message.rb:8:in `__run'

As you can see above line 8 is {message.list_address.email} in this case. Unless, of course, '8' has nothing to do with the line number!?

If I state this: {message.list_address} all mail -not just the from the addresses stated in the file- are labeled 'lists'.

I looked at the post[1] where Hamish helped me by suggesting I state message.list_address.email to reference the list-post in the header and it worked fine at that time. I continued to play aroudn with things to try and get the hook to not only add 'lists' but add the relevant list name as well as remove the 'inbox' label. That didn't work so I tried going back to basics and just have the hook label the relevant mails as 'lists' and now I can't even do that.

What Have I done to make this not work anymore?

ref
[1]http://rubyforge.org/pipermail/sup-talk/2011-February/004495.html
-- 
Thanks,
Phil
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [sup-talk] More before-add hook issues
  2011-02-15 14:55 [sup-talk] More before-add hook issues Philippe LeCavalier
@ 2011-02-16  9:31 ` Tero Tilus
  2011-02-16 14:35   ` Philippe LeCavalier
  0 siblings, 1 reply; 3+ messages in thread
From: Tero Tilus @ 2011-02-16  9:31 UTC (permalink / raw)
  To: Sup users

Philippe LeCavalier, 2011-02-15 16:55:
> 8 if ! addressfile.grep(/#{message.list_address.email}/).empty?

Try

if message.list_address && !addressfile.grep(/#{message.list_address.email}/).empty?

-- 
Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [sup-talk] More before-add hook issues
  2011-02-16  9:31 ` Tero Tilus
@ 2011-02-16 14:35   ` Philippe LeCavalier
  0 siblings, 0 replies; 3+ messages in thread
From: Philippe LeCavalier @ 2011-02-16 14:35 UTC (permalink / raw)
  To: Tero Tilus; +Cc: Sup users

Hi Tero.
Excerpts from Tero Tilus's message of Wed Feb 16 04:31:17 -0500 2011:
> Philippe LeCavalier, 2011-02-15 16:55:
> > 8 if ! addressfile.grep(/#{message.list_address.email}/).empty?
> 
> Try
> 
> if message.list_address && !addressfile.grep(/#{message.list_address.email}/).empty?
> 
It worked! Thanks Tero. Just for everyone's benefit this is what the complete rule looks like:

  7   if message.list_address &&
  8   addressfile = File.open("/home/plecavalier/.sup/hooks/label.list","r")
  9   !addressfile.grep(/#{message.list_address.email}/).empty?
 10  message.add_label :list
 11 end

Tero, I'm assuming this is what you expected me to do!? Would I be able to add more functions:

i) read a list of addresses in a second file ie label.list.sup against list-post header from each list and label accordingly ie if it's sup-talk@rubyforge assign label: sup if it's cups->cups...and so on?
ii) lastly, remove :inbox

I'm asking in that fashion because in my experience thus far if I go and build rules for each list to:
a) label :list
b) label :<list_name>
c) -label :inbox
d) wash, rinse and repeat for each list

the hook dies. So it's apparent to me that all functions need to occur in the same invocation. ie multiple, separate functions on the same msg fails. I found a post somewhere(which I can't seem to find anymore) where someone stated multiple invocations on the same msg isn't possible but there must be a workaround...Someone must be applying more than one label to a msg at the same time. Isn't there someone out there succeeding at this?


-- 
Thanks,
Phil
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-16 15:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-15 14:55 [sup-talk] More before-add hook issues Philippe LeCavalier
2011-02-16  9:31 ` Tero Tilus
2011-02-16 14:35   ` Philippe LeCavalier

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