app/models/mail_notify.rb in parlement-0.9 vs app/models/mail_notify.rb in parlement-0.10
- old
+ new
@@ -9,11 +9,11 @@
logger.info "Create a mail for publication"
subject elt.subject
ml = mailing_list(elt.parent)
- recipients (ml.subject.blank? ? '' : ml.subject ) \
+ recipients ml.subject.to_s \
+ " <#{ml.id}@#{ActionMailer::Base.server_settings[:domain]}>"
from ((elt.person and elt.person.name) ? elt.person.name : ANONYMOUS_POSTER) \
+ " <" \
+ ((elt.person and elt.person.email) \
@@ -56,10 +56,11 @@
@sent_on = elt.created_on
parentMsg = elt.parent.mail
if parentMsg
+ parentMsg.reload # Mostly necessary for tests
@headers['references'] = ''
@headers['references'] << parentMsg.mail_parents if parentMsg.mail_parents
@headers['references'] << parentMsg.message if parentMsg.message
end
@@ -69,16 +70,16 @@
end
private
#
- # Try to fine, define, the mailing list id this elt is part of
+ # Try to find, define, the mailing list id this elt is part of
#
- # The algo used is simple: find a parent id smaller than the usually auto
- # generated ids
+ # The algo used is simple: find a small parent id which does not correspond
+ # to an answer
#
def mailing_list(elt)
- if (elt.id.size > 21 and elt.parent_id != 'ROOT' and !elt.subject.match 'Re: ') then
+ if (elt and elt.parent_id and elt.parent_id != 'ROOT' and (elt.id.size > 21 or elt.subject =~ /Re:\s/)) then
mailing_list elt.parent
else
elt
end
end