Add In-Reply-To and References headers to notification mails

closes #7122
This commit is contained in:
Dennis Schubert 2016-09-25 05:38:28 +02:00 committed by Benjamin Neff
parent 6ca598e54a
commit dfb5b717b6
8 changed files with 38 additions and 1 deletions

View file

@ -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 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) * 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) * 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 # 0.6.0.1

View file

@ -8,6 +8,7 @@ module NotificationMailers
if mail? if mail?
@headers[:from] = "\"#{@comment.author_name} (diaspora*)\" <#{AppConfig.mail.sender_address}>" @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? if @comment.public?
@headers[:subject] = "Re: #{@comment.comment_email_subject}" @headers[:subject] = "Re: #{@comment.comment_email_subject}"
else else

View file

@ -6,6 +6,7 @@ module NotificationMailers
@comment = Comment.find(comment_id) @comment = Comment.find(comment_id)
@headers[:from] = "\"#{@comment.author_name} (diaspora*)\" <#{AppConfig.mail.sender_address}>" @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? if @comment.public?
@headers[:subject] = "Re: #{@comment.comment_email_subject}" @headers[:subject] = "Re: #{@comment.comment_email_subject}"
else else

View file

@ -7,6 +7,7 @@ module NotificationMailers
@like = Like.find(like_id) @like = Like.find(like_id)
@headers[:subject] = I18n.t('notifier.liked.liked', :name => @sender.name) @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 end
end end

View file

@ -7,6 +7,7 @@ module NotificationMailers
@post = Mention.find_by_id(target_id).post @post = Mention.find_by_id(target_id).post
@headers[:subject] = I18n.t('notifier.mentioned.subject', :name => @sender.name) @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 end
end end

View file

@ -9,6 +9,7 @@ module NotificationMailers
@headers[:from] = "\"#{@message.author_name} (diaspora*)\" <#{AppConfig.mail.sender_address}>" @headers[:from] = "\"#{@message.author_name} (diaspora*)\" <#{AppConfig.mail.sender_address}>"
@headers[:subject] = I18n.t("notifier.private_message.subject") @headers[:subject] = I18n.t("notifier.private_message.subject")
@headers[:in_reply_to] = @headers[:references] = "<#{@conversation.guid}@#{AppConfig.pod_uri.host}>"
end end
end end
end end

View file

@ -1,13 +1,14 @@
module NotificationMailers module NotificationMailers
class Reshared < NotificationMailers::Base class Reshared < NotificationMailers::Base
attr_accessor :reshare attr_accessor :reshare
delegate :root, to: :reshare, prefix: true delegate :root, to: :reshare, prefix: true
def set_headers(reshare_id) def set_headers(reshare_id)
@reshare = Reshare.find(reshare_id) @reshare = Reshare.find(reshare_id)
@headers[:subject] = I18n.t('notifier.reshared.reshared', :name => @sender.name) @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 end
end end

View file

@ -94,6 +94,11 @@ describe Notifier, type: :mailer do
expect(@mail.subject).to include(@post.author.name) expect(@mail.subject).to include(@post.author.name)
end 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 it "has the post text in the body" do
expect(@mail.body.encoded).to include(@post.text) expect(@mail.body.encoded).to include(@post.text)
end end
@ -170,6 +175,11 @@ describe Notifier, type: :mailer do
expect(@mail.to).to eq([alice.email]) expect(@mail.to).to eq([alice.email])
end 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 it "BODY: contains the truncated original post" do
expect(@mail.body.encoded).to include(@post.message.plain_text) expect(@mail.body.encoded).to include(@post.message.plain_text)
end end
@ -216,6 +226,11 @@ describe Notifier, type: :mailer do
expect(@mail.subject).not_to include(@cnv.subject) expect(@mail.subject).not_to include(@cnv.subject)
end 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 it "BODY: does not contain the message text" do
expect(@mail.body.encoded).not_to include(@cnv.messages.first.text) expect(@mail.body.encoded).not_to include(@cnv.messages.first.text)
end end
@ -290,6 +305,11 @@ describe Notifier, type: :mailer do
expect(comment_mail.subject).to eq("Re: Headline") expect(comment_mail.subject).to eq("Re: Headline")
end 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 context "BODY" do
it "contains the comment" do it "contains the comment" do
expect(comment_mail.body.encoded).to include(comment.text) 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") expect(mail.subject).not_to include("Limited headline")
end 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 it "BODY: does not show the limited post" do
expect(mail.body.encoded).not_to include("Limited headline") expect(mail.body.encoded).not_to include("Limited headline")
end end
@ -391,6 +416,11 @@ describe Notifier, type: :mailer do
expect(mail.subject).not_to include("Limited headline") expect(mail.subject).not_to include("Limited headline")
end 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 it "BODY: does not show the limited post" do
expect(mail.body.encoded).not_to include("Limited headline") expect(mail.body.encoded).not_to include("Limited headline")
end end