* [sup-talk] [PATCH] Add list-id as a new property of messages
@ 2008-04-23 21:23 Israel Herraiz
2008-04-24 8:54 ` Marcus Williams
0 siblings, 1 reply; 4+ messages in thread
From: Israel Herraiz @ 2008-04-23 21:23 UTC (permalink / raw)
Hi there,
I propose to add a "list_id" property to messages, just like
list_subscribe, list_unsubscribe and list_address.
I am using list_address.email to automatically generate labels for
messages that are coming from mailing lists (that field uses the value
of the List-Post header of the raw message). It seems that some
mailing lists are not including that header though. In those lists
where I do not see List-Post, I have found that List-Id is still
present. Therefore I propose to add that header to the message class
for filtering purposes.
The change is minimal, and as far as I have found out, it does not
affect any other part of Sup (like for instance the index of
messages). I am attaching the patch below.
Cheers,
Israel
---
lib/sup/mbox.rb | 1 +
lib/sup/message.rb | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/lib/sup/mbox.rb b/lib/sup/mbox.rb
index f267b3b..35d0283 100644
--- a/lib/sup/mbox.rb
+++ b/lib/sup/mbox.rb
@@ -32,6 +32,7 @@ module MBox
/^(List-Post):\s*(.*?)\s*$/i,
/^(List-Subscribe):\s*(.*?)\s*$/i,
/^(List-Unsubscribe):\s*(.*?)\s*$/i,
+ /^(List-Id):\s*(.*?)\s*$/i,
/^(Status):\s*(.*?)\s*$/i: header[last = $1] = $2
when /^(Message-Id):\s*(.*?)\s*$/i: header[mid_field = last = $1] = $2
diff --git a/lib/sup/message.rb b/lib/sup/message.rb
index 249b6c6..3952236 100644
--- a/lib/sup/message.rb
+++ b/lib/sup/message.rb
@@ -38,7 +38,7 @@ class Message
attr_reader :id, :date, :from, :subj, :refs, :replytos, :to, :source,
:cc, :bcc, :labels, :list_address, :recipient_email, :replyto,
- :source_info, :list_subscribe, :list_unsubscribe
+ :source_info, :list_subscribe, :list_unsubscribe, :list_id
bool_reader :dirty, :source_marked_read, :snippet_contains_encrypted_content
@@ -128,6 +128,12 @@ class Message
@source_marked_read = header["status"] == "RO"
@list_subscribe = header["list-subscribe"]
@list_unsubscribe = header["list-unsubscribe"]
+ @list_id =
+ if header["list-id"]
+ @list_id = PersonManager.person_for header["list-id"]
+ else
+ nil
+ end
end
private :parse_header
--
1.5.5
^ permalink raw reply [flat|nested] 4+ messages in thread
* [sup-talk] [PATCH] Add list-id as a new property of messages
2008-04-23 21:23 [sup-talk] [PATCH] Add list-id as a new property of messages Israel Herraiz
@ 2008-04-24 8:54 ` Marcus Williams
2008-04-25 20:46 ` Israel Herraiz
0 siblings, 1 reply; 4+ messages in thread
From: Marcus Williams @ 2008-04-24 8:54 UTC (permalink / raw)
On 23.4.2008, Israel Herraiz wrote:
> I am using list_address.email to automatically generate labels for
> messages that are coming from mailing lists (that field uses the value
> of the List-Post header of the raw message). It seems that some
> mailing lists are not including that header though. In those lists
> where I do not see List-Post, I have found that List-Id is still
> present. Therefore I propose to add that header to the message class
> for filtering purposes.
Adding list-id is a good idea I think but you cant do a personmanager
lookup with it because it isnt really an email address according to
the RFC [1]. List-Subscribe and List-Unsubscribe all set their
counterparts in message.rb to the raw header so this is what I would
expect list_id to get set to.
[snip]
> @@ -128,6 +128,12 @@ class Message
> @source_marked_read = header["status"] == "RO"
> @list_subscribe = header["list-subscribe"]
> @list_unsubscribe = header["list-unsubscribe"]
> + @list_id =
> + if header["list-id"]
> + @list_id = PersonManager.person_for header["list-id"]
> + else
> + nil
> + end
> end
> private :parse_header
[snip]
If you are labeling via list-id you just want the raw header so this
should just be
@list_id = header["list-id"]
Then if you want to do a lookup you can do it in the
before-add-message hook.
Marcus
[1] http://www.apps.ietf.org/rfc/rfc2919.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* [sup-talk] [PATCH] Add list-id as a new property of messages
2008-04-24 8:54 ` Marcus Williams
@ 2008-04-25 20:46 ` Israel Herraiz
2008-04-25 21:15 ` Marcus Williams
0 siblings, 1 reply; 4+ messages in thread
From: Israel Herraiz @ 2008-04-25 20:46 UTC (permalink / raw)
Excerpts from Marcus Williams's message of Thu Apr 24 10:54:53 +0200 2008:
> Adding list-id is a good idea I think but you cant do a personmanager
> lookup with it because it isnt really an email address according to
> the RFC [1]. List-Subscribe and List-Unsubscribe all set their
> counterparts in message.rb to the raw header so this is what I would
> expect list_id to get set to.
Yes, I know. The "problem" is that List-Id use to have two fields: one
that is a name, and another one that is a address-like. I wanted to
use that last field and no the name for the automatic label. That's
why I have used PersonManager to process the List-Id header.
I know it is not a "dirty hack", but after all the regular expression
to obtain that part of List-Id is the same that to obtain the address
of List-Post. So I thought it was not that bad to use PersonManager to
apply the same regular expression.
Cheers,
Israel
^ permalink raw reply [flat|nested] 4+ messages in thread
* [sup-talk] [PATCH] Add list-id as a new property of messages
2008-04-25 20:46 ` Israel Herraiz
@ 2008-04-25 21:15 ` Marcus Williams
0 siblings, 0 replies; 4+ messages in thread
From: Marcus Williams @ 2008-04-25 21:15 UTC (permalink / raw)
On 25.4.2008, Israel Herraiz wrote:
> Yes, I know. The "problem" is that List-Id use to have two fields: one
> that is a name, and another one that is a address-like. I wanted to
> use that last field and no the name for the automatic label. That's
> why I have used PersonManager to process the List-Id header.
:) I'm not saying you shouldnt do it - just that personally I dont
think you should do it in the place you do it. If you make list-id the
raw header in your patch then you can do the person manager lookup in
your before-add-message labeling hook (assuming thats where you're
labeling stuff). That way someone that wants to do something different
with the list-id header can do because you've given them the raw
header contents.
Having said all that, you can access the raw headers directly from the
message object in the hook anyway so maybe this is a non-issue. I'll
shut up :)
Marcus
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-04-25 21:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-23 21:23 [sup-talk] [PATCH] Add list-id as a new property of messages Israel Herraiz
2008-04-24 8:54 ` Marcus Williams
2008-04-25 20:46 ` Israel Herraiz
2008-04-25 21:15 ` Marcus Williams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox