Comment: for emailed comments, show that in the message id used for mailing list

This commit is contained in:
joshua stein 2015-12-02 13:45:50 -06:00
parent 5d8c7f7167
commit 4e94bc9e29
2 changed files with 13 additions and 6 deletions

View file

@ -356,7 +356,12 @@ class Comment < ActiveRecord::Base
end
def mailing_list_message_id
"comment.#{short_id}.#{created_at.to_i}@#{Rails.application.domain}"
[
"comment",
self.short_id,
self.is_from_email ? "email" : nil,
created_at.to_i
].reject{|p| !p }.join(".") << "@" << Rails.application.domain
end
def path

View file

@ -174,7 +174,13 @@ last_comment_id, false, false).order(:id).each do |c|
IO.popen([ {}, "/usr/sbin/sendmail", "-i", "-f",
"nobody@#{domain}", u.email ], "w") do |mail|
mail.puts "From: #{c.user.username} <#{c.user.username}@#{domain}>"
from = "From: \"#{c.user.username}"
if c.hat
from << " (#{c.hat.hat})"
end
from << "\" <#{c.user.username}@#{domain}>"
mail.puts from
mail.puts "Reply-To: #{list}"
mail.puts "To: #{list}"
mail.puts "List-Id: #{Rails.application.name} <#{list}>"
@ -214,10 +220,6 @@ last_comment_id, false, false).order(:id).each do |c|
mail.puts " #{ref}"
end
if c.hat
mail.puts "X-Hat: #{c.hat.hat}"
end
mail.puts "Date: " << c.created_at.strftime("%a, %d %b %Y %H:%M:%S %z")
mail.puts "Subject: Re: " << c.story.title.force_to_ascii <<
c.story.tags.sort_by{|t| t.tag }.map{|t| " [#{t.tag}]" }.join