Subject: Re: [sup-talk] message.list_address weirdness

From: Matthias Vallentin <[email-masked]>
Date: Sun, 02 Jan 2011 08:13:39 -0800

On Dec 27 2010 at 02:07AM PST, Matthias Vallentin wrote:
> I cannot get message.list_address to match to add labels before adding
> messages although the messages definitively have the List-Post header.

Actually, the proposed changes will cause a crash when replying to a
list address (i.e., hitting 'G'), which expects message.list_address to
return a Person object rather than a string containing the email
address. This is inconsistent with the wiki [1] and started my confusion
in the first place. Automatically adding labels for mailing lists would
then change from

    if message.list_address =~ /sup-talk/
      message.add_label "sup"
      message.add_label "list"
    end

to

    if message.list_address and message.list_address.email =~ /sup-talk/
      message.add_label "sup"
      message.add_label "list"
    end

in order to work correctly. In [1], list_address is documented to be of
type String, which should probably be changed to type Person. I find the
naming (list_address) slightly misleading because it suggest a plain
email address. What about introducing a new member message.list that
returns a Person object and making
message.list_{address,subscribe,unsubscribe} return a string?

    Matthias

[1] http://sup.rubyforge.org/wiki/wiki.pl?AutoAddLabelsToNewMessages
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Matthias Vallentin <[email-masked]>
Date: Mon, 27 Dec 2010 02:07:18 -0800

I cannot get message.list_address to match to add labels before adding
messages although the messages definitively have the List-Post header.
I found that message.list_address is sometimes a Person instance, which 
suggest a bug in the code assigning the instance variable @list_address
(reformatted):

@list_address = if header["list-post"]
                  address = if header["list-post"] =~ /mailto:(.*?)[>\s$]/
                              $1
                            elsif header["list-post"] =~ /@/
                              header["list-post"] # just try the whole fucking thing
                            end
                  address && Person.from_address(address)
                elsif header["x-mailing-list"]
                  Person.from_address header["x-mailing-list"]
                end

This code looks erroneous in that Person.from_address returns a Person
instance in the elsif branch. Shouldn't that be a string of the address
instead, i.e.,

    Person.from_address(header["x-mailing-list"]).email

? The same problem seems to appear in the conjunction

    address && Person.from_address(address)

which should in my opinion be

    address && Person.from_address(address).email

. Does that makes sense?

   Matthias