Subject: [sup-talk] Hook, again

From: [email-masked] (Guillaume Quintard)
Date: Sat, 26 Sep 2009 20:09:56 +0200

Sorry to come back again with that issue, but I'm having trouble with
the reply-from hook. Here's what I have:

message.recipients.each {
    |person|
	if (person.email =~ /addr at site.com/) != nil
		Person.from_address "Foo  <bar at site.org>"
	end 
}

But it doesn't seem to work. 
If I reply to a mail addressed to addr at site.com, the log says nothing, but the from field isn't changed.
If I reply to any other mail, le log complains I didn't return a Person
And if I just put Person.from_address "Foo  <addr at site.org>" in the
hook, the from field is correctly changed.

I'm a bit lost on that one (still not knowing alot of ruby doesn't help
I must say). Am I missing the obvious here?

Cheers.

-- 
Guillaume

---

From: [email-masked] (William Morgan)
Date: Sat, 26 Sep 2009 18:27:57 -0700

>         Person.from_address "Foo  <bar at site.org>"

The problem is that #each returns the original array, i.e.
message.recipients. Your Person object is getting constructed and then
forgotten.

Try:

if messages.recipients.any? { |p| p.email =~ /addr at site\.com/ }
  Person.from_address "Foo <bar at site.org>"
end

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