[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sup-talk] best method for before-add-message.rb
Hi,
what would be the best way to match - for instance - the List-Id-Header in case
it's present? I've been wondering about this for a long time, right now, I'm
matching the raw-header against some regex, but it breaks if the line I'm
matching contains a newline (i.e. the header field is longer than one line).
Is there any way around this? Right now I'm doing something along the lines of
this:
# Mailing lists
lids_re = {
/<foo\.lists\.foo\.com>/ => "foo",
/<dev\.something\.org>/ => ["something", "devel"]
}
def add_labels message, labels
labels.each do |l|
message.add_label l
end
end
if message.raw_header =~ /^List-I[dD]: ([^\n]+)/
#log "List ID: #{$1}"
message.add_label "list"
lids_re.keys.each do |re|
add_labels message lids_re[re] if $1 =~ re
end
end
Can I pull arbitrary, parsed headers directly out of the message object, or do
I have to do my own parsing?
Best regards,
Moritz
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk