From 4e94bc9e29d9ded6360f733e4dbd1ecd87e4e250 Mon Sep 17 00:00:00 2001 From: joshua stein Date: Wed, 2 Dec 2015 13:45:50 -0600 Subject: [PATCH] Comment: for emailed comments, show that in the message id used for mailing list --- app/models/comment.rb | 7 ++++++- script/mail_new_activity | 12 +++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index cb82753..352d965 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -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 diff --git a/script/mail_new_activity b/script/mail_new_activity index 1565690..4abd9fe 100755 --- a/script/mail_new_activity +++ b/script/mail_new_activity @@ -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