diff --git a/Changelog.md b/Changelog.md index 0005cad8d..14cfb2502 100644 --- a/Changelog.md +++ b/Changelog.md @@ -37,6 +37,7 @@ Note: Although this is a minor release, the configuration file changed because t * Add support for setting BOSH access protocol via chat configuration [#7100](https://github.com/diaspora/diaspora/pull/7100) * Add number of unreviewed reports to admin dashboard and admin sidebar [#7109](https://github.com/diaspora/diaspora/pull/7109) * Don't federate to pods that have been offline for an extended period of time [#7120](https://github.com/diaspora/diaspora/pull/7120) +* Add In-Reply-To and References headers to notification mails [#7122](https://github.com/diaspora/diaspora/pull/7122) # 0.6.0.1 diff --git a/app/mailers/notification_mailers/also_commented.rb b/app/mailers/notification_mailers/also_commented.rb index 15914d25a..aa063cfa8 100644 --- a/app/mailers/notification_mailers/also_commented.rb +++ b/app/mailers/notification_mailers/also_commented.rb @@ -8,6 +8,7 @@ module NotificationMailers if mail? @headers[:from] = "\"#{@comment.author_name} (diaspora*)\" <#{AppConfig.mail.sender_address}>" + @headers[:in_reply_to] = @headers[:references] = "<#{@comment.parent.guid}@#{AppConfig.pod_uri.host}>" if @comment.public? @headers[:subject] = "Re: #{@comment.comment_email_subject}" else diff --git a/app/mailers/notification_mailers/comment_on_post.rb b/app/mailers/notification_mailers/comment_on_post.rb index 1ad0a5f0f..4782f52b2 100644 --- a/app/mailers/notification_mailers/comment_on_post.rb +++ b/app/mailers/notification_mailers/comment_on_post.rb @@ -6,6 +6,7 @@ module NotificationMailers @comment = Comment.find(comment_id) @headers[:from] = "\"#{@comment.author_name} (diaspora*)\" <#{AppConfig.mail.sender_address}>" + @headers[:in_reply_to] = @headers[:references] = "<#{@comment.parent.guid}@#{AppConfig.pod_uri.host}>" if @comment.public? @headers[:subject] = "Re: #{@comment.comment_email_subject}" else diff --git a/app/mailers/notification_mailers/liked.rb b/app/mailers/notification_mailers/liked.rb index 54e89ef90..c9067bf74 100644 --- a/app/mailers/notification_mailers/liked.rb +++ b/app/mailers/notification_mailers/liked.rb @@ -7,6 +7,7 @@ module NotificationMailers @like = Like.find(like_id) @headers[:subject] = I18n.t('notifier.liked.liked', :name => @sender.name) + @headers[:in_reply_to] = @headers[:references] = "<#{@like.parent.guid}@#{AppConfig.pod_uri.host}>" end end end diff --git a/app/mailers/notification_mailers/mentioned.rb b/app/mailers/notification_mailers/mentioned.rb index dc64f65b0..a06c82e75 100644 --- a/app/mailers/notification_mailers/mentioned.rb +++ b/app/mailers/notification_mailers/mentioned.rb @@ -7,6 +7,7 @@ module NotificationMailers @post = Mention.find_by_id(target_id).post @headers[:subject] = I18n.t('notifier.mentioned.subject', :name => @sender.name) + @headers[:in_reply_to] = @headers[:references] = "<#{@post.guid}@#{AppConfig.pod_uri.host}>" end end end diff --git a/app/mailers/notification_mailers/private_message.rb b/app/mailers/notification_mailers/private_message.rb index ed40e70dd..9cbe71dc3 100644 --- a/app/mailers/notification_mailers/private_message.rb +++ b/app/mailers/notification_mailers/private_message.rb @@ -9,6 +9,7 @@ module NotificationMailers @headers[:from] = "\"#{@message.author_name} (diaspora*)\" <#{AppConfig.mail.sender_address}>" @headers[:subject] = I18n.t("notifier.private_message.subject") + @headers[:in_reply_to] = @headers[:references] = "<#{@conversation.guid}@#{AppConfig.pod_uri.host}>" end end end diff --git a/app/mailers/notification_mailers/reshared.rb b/app/mailers/notification_mailers/reshared.rb index 4ea24e13d..e98b986ab 100644 --- a/app/mailers/notification_mailers/reshared.rb +++ b/app/mailers/notification_mailers/reshared.rb @@ -1,13 +1,14 @@ module NotificationMailers class Reshared < NotificationMailers::Base attr_accessor :reshare - + delegate :root, to: :reshare, prefix: true def set_headers(reshare_id) @reshare = Reshare.find(reshare_id) @headers[:subject] = I18n.t('notifier.reshared.reshared', :name => @sender.name) + @headers[:in_reply_to] = @headers[:references] = "<#{@reshare.root_guid}@#{AppConfig.pod_uri.host}>" end end end diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 3669fddd9..f56b27c00 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -94,6 +94,11 @@ describe Notifier, type: :mailer do expect(@mail.subject).to include(@post.author.name) end + it "IN-REPLY-TO and REFERENCES: references the mentioning post" do + expect(@mail.in_reply_to).to eq("#{@post.guid}@#{AppConfig.pod_uri.host}") + expect(@mail.references).to eq("#{@post.guid}@#{AppConfig.pod_uri.host}") + end + it "has the post text in the body" do expect(@mail.body.encoded).to include(@post.text) end @@ -170,6 +175,11 @@ describe Notifier, type: :mailer do expect(@mail.to).to eq([alice.email]) end + it "IN-REPLY-TO and REFERENCES: references the reshared post" do + expect(@mail.in_reply_to).to eq("#{@post.guid}@#{AppConfig.pod_uri.host}") + expect(@mail.references).to eq("#{@post.guid}@#{AppConfig.pod_uri.host}") + end + it "BODY: contains the truncated original post" do expect(@mail.body.encoded).to include(@post.message.plain_text) end @@ -216,6 +226,11 @@ describe Notifier, type: :mailer do expect(@mail.subject).not_to include(@cnv.subject) end + it "IN-REPLY-TO and REFERENCES: references the containing conversation" do + expect(@mail.in_reply_to).to eq("#{@cnv.guid}@#{AppConfig.pod_uri.host}") + expect(@mail.references).to eq("#{@cnv.guid}@#{AppConfig.pod_uri.host}") + end + it "BODY: does not contain the message text" do expect(@mail.body.encoded).not_to include(@cnv.messages.first.text) end @@ -290,6 +305,11 @@ describe Notifier, type: :mailer do expect(comment_mail.subject).to eq("Re: Headline") end + it "IN-REPLY-TO and REFERENCES: references the commented post" do + expect(comment_mail.in_reply_to).to eq("#{comment.parent.guid}@#{AppConfig.pod_uri.host}") + expect(comment_mail.references).to eq("#{comment.parent.guid}@#{AppConfig.pod_uri.host}") + end + context "BODY" do it "contains the comment" do expect(comment_mail.body.encoded).to include(comment.text) @@ -365,6 +385,11 @@ describe Notifier, type: :mailer do expect(mail.subject).not_to include("Limited headline") end + it "IN-REPLY-TO and REFERENCES: references the commented post" do + expect(mail.in_reply_to).to eq("#{comment.parent.guid}@#{AppConfig.pod_uri.host}") + expect(mail.references).to eq("#{comment.parent.guid}@#{AppConfig.pod_uri.host}") + end + it "BODY: does not show the limited post" do expect(mail.body.encoded).not_to include("Limited headline") end @@ -391,6 +416,11 @@ describe Notifier, type: :mailer do expect(mail.subject).not_to include("Limited headline") end + it "IN-REPLY-TO and REFERENCES: references the liked post" do + expect(mail.in_reply_to).to eq("#{like.parent.guid}@#{AppConfig.pod_uri.host}") + expect(mail.references).to eq("#{like.parent.guid}@#{AppConfig.pod_uri.host}") + end + it "BODY: does not show the limited post" do expect(mail.body.encoded).not_to include("Limited headline") end