Merge pull request #5877 from SuperTux88/fix-notification-mails
fix notification mails for limited posts
This commit is contained in:
commit
67a6c8be0c
8 changed files with 69 additions and 16 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
* Return 406 when requesting a JSON representation of people/:guid/contacts [#5849](https://github.com/diaspora/diaspora/pull/5849)
|
* Return 406 when requesting a JSON representation of people/:guid/contacts [#5849](https://github.com/diaspora/diaspora/pull/5849)
|
||||||
* Destroy Participation when removing interactions with a post [#5852](https://github.com/diaspora/diaspora/pull/5852)
|
* Destroy Participation when removing interactions with a post [#5852](https://github.com/diaspora/diaspora/pull/5852)
|
||||||
* Hide manage services link in the publisher on certain pages [#5854](https://github.com/diaspora/diaspora/pull/5854)
|
* Hide manage services link in the publisher on certain pages [#5854](https://github.com/diaspora/diaspora/pull/5854)
|
||||||
|
* Fix notification mails for limited posts [#5877](https://github.com/diaspora/diaspora/pull/5877)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* Hide post title of limited post in comment notification email [#5843](https://github.com/diaspora/diaspora/pull/5843)
|
* Hide post title of limited post in comment notification email [#5843](https://github.com/diaspora/diaspora/pull/5843)
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,7 @@ module NotifierHelper
|
||||||
# @param opts [Hash] Optional hash. Accepts :length parameters.
|
# @param opts [Hash] Optional hash. Accepts :length parameters.
|
||||||
# @return [String] The formatted post.
|
# @return [String] The formatted post.
|
||||||
def post_message(post, opts={})
|
def post_message(post, opts={})
|
||||||
if !post.public?
|
if post.respond_to? :message
|
||||||
I18n.translate 'notifier.a_private_message'
|
|
||||||
elsif post.respond_to? :message
|
|
||||||
post.message.plain_text_without_markdown
|
post.message.plain_text_without_markdown
|
||||||
else
|
else
|
||||||
I18n.translate 'notifier.a_post_you_shared'
|
I18n.translate 'notifier.a_post_you_shared'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
|
<% if @notification.like_target.public? %>
|
||||||
<%= "#{t('.liked', :name => "#{@notification.sender_name}")}:" %>
|
<%= "#{t('.liked', :name => "#{@notification.sender_name}")}:" %>
|
||||||
|
|
||||||
<%= post_message(@notification.like_target, :process_newlines => true) %>
|
<%= post_message(@notification.like_target, :process_newlines => true) %>
|
||||||
|
<% else %>
|
||||||
|
<%= "#{t('notifier.liked.limited_post', :name => "#{@notification.sender_name}")}." %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
[<%= t('.view_post') %>][1]
|
[<%= t('.view_post') %>][1]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
|
<% if @notification.post.public? %>
|
||||||
<%= post_message(@notification.post, :process_newlines => true) %>
|
<%= post_message(@notification.post, :process_newlines => true) %>
|
||||||
|
<% else %>
|
||||||
|
<%= t('notifier.mentioned.limited_post') %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
[<%= t('notifier.comment_on_post.reply', :name => @notification.post_author_name) %>][1]
|
[<%= t('notifier.comment_on_post.reply', :name => @notification.post_author_name) %>][1]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<%= post_message(@notification.message, :process_newlines => true) %>
|
<%= t('notifier.a_private_message') %>
|
||||||
|
|
||||||
[<%= t('.reply_to_or_view') %>][1]
|
[<%= t('.reply_to_or_view') %>][1]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -759,10 +759,12 @@ en:
|
||||||
mentioned:
|
mentioned:
|
||||||
subject: "%{name} has mentioned you on diaspora*"
|
subject: "%{name} has mentioned you on diaspora*"
|
||||||
mentioned: "mentioned you in a post:"
|
mentioned: "mentioned you in a post:"
|
||||||
|
limited_post: "You were mentioned in a limited post."
|
||||||
private_message:
|
private_message:
|
||||||
reply_to_or_view: "Reply to or view this conversation >"
|
reply_to_or_view: "Reply to or view this conversation >"
|
||||||
liked:
|
liked:
|
||||||
liked: "%{name} liked your post"
|
liked: "%{name} liked your post"
|
||||||
|
limited_post: "%{name} liked your limited post"
|
||||||
view_post: "View post >"
|
view_post: "View post >"
|
||||||
reshared:
|
reshared:
|
||||||
reshared: "%{name} reshared your post"
|
reshared: "%{name} reshared your post"
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,10 @@ describe NotifierHelper, :type => :helper do
|
||||||
@markdown_post = FactoryGirl.create(:status_message,
|
@markdown_post = FactoryGirl.create(:status_message,
|
||||||
text: "[link](http://diasporafoundation.org) **bold text** *other text*", public: true)
|
text: "[link](http://diasporafoundation.org) **bold text** *other text*", public: true)
|
||||||
@striped_markdown_post = "link (http://diasporafoundation.org) bold text other text"
|
@striped_markdown_post = "link (http://diasporafoundation.org) bold text other text"
|
||||||
|
|
||||||
@limited_post = FactoryGirl.create(:status_message, text: "This is top secret post. Shhhhhhhh!!!", public: false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'strip markdown in the post' do
|
|
||||||
expect(post_message(@markdown_post)).to eq(@striped_markdown_post)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'hides the private content' do
|
it 'strip markdown in the post' do
|
||||||
expect(post_message(@limited_post)).not_to include("secret post")
|
expect(post_message(@markdown_post)).to eq(@striped_markdown_post)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -31,17 +25,17 @@ describe NotifierHelper, :type => :helper do
|
||||||
@markdown_comment.post.public = true
|
@markdown_comment.post.public = true
|
||||||
@markdown_comment.text = "[link](http://diasporafoundation.org) **bold text** *other text*"
|
@markdown_comment.text = "[link](http://diasporafoundation.org) **bold text** *other text*"
|
||||||
@striped_markdown_comment = "link (http://diasporafoundation.org) bold text other text"
|
@striped_markdown_comment = "link (http://diasporafoundation.org) bold text other text"
|
||||||
|
|
||||||
# comment for limited post
|
# comment for limited post
|
||||||
@limited_comment = FactoryGirl.create(:comment)
|
@limited_comment = FactoryGirl.create(:comment)
|
||||||
@limited_comment.post.public = false
|
@limited_comment.post.public = false
|
||||||
@limited_comment.text = "This is top secret comment. Shhhhhhhh!!!"
|
@limited_comment.text = "This is top secret comment. Shhhhhhhh!!!"
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'strip markdown in the comment' do
|
it 'strip markdown in the comment' do
|
||||||
expect(comment_message(@markdown_comment)).to eq(@striped_markdown_comment)
|
expect(comment_message(@markdown_comment)).to eq(@striped_markdown_comment)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'hides the private content' do
|
it 'hides the private content' do
|
||||||
expect(comment_message(@limited_comment)).not_to include("secret comment")
|
expect(comment_message(@limited_comment)).not_to include("secret comment")
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,32 @@ describe Notifier, :type => :mailer do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe ".mentioned limited" do
|
||||||
|
before do
|
||||||
|
@user = alice
|
||||||
|
@post = FactoryGirl.create(:status_message, public: false)
|
||||||
|
@mention = Mention.create(person: @user.person, post: @post)
|
||||||
|
|
||||||
|
@mail = Notifier.mentioned(@user.id, @post.author.id, @mention.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "TO: goes to the right person" do
|
||||||
|
expect(@mail.to).to eq([@user.email])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "SUBJECT: has the name of person mentioning in the subject" do
|
||||||
|
expect(@mail.subject).to include(@post.author.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "has the post text not in the body" do
|
||||||
|
expect(@mail.body.encoded).not_to include(@post.text)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not include translation fallback" do
|
||||||
|
expect(@mail.body.encoded).not_to include(I18n.translate "notifier.a_post_you_shared")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe ".liked" do
|
describe ".liked" do
|
||||||
before do
|
before do
|
||||||
@post = FactoryGirl.create(:status_message, :author => alice.person, :public => true)
|
@post = FactoryGirl.create(:status_message, :author => alice.person, :public => true)
|
||||||
|
|
@ -131,7 +157,31 @@ describe Notifier, :type => :mailer do
|
||||||
it 'can handle a reshare' do
|
it 'can handle a reshare' do
|
||||||
reshare = FactoryGirl.create(:reshare)
|
reshare = FactoryGirl.create(:reshare)
|
||||||
like = reshare.likes.create!(:author => bob.person)
|
like = reshare.likes.create!(:author => bob.person)
|
||||||
mail = Notifier.liked(alice.id, like.author.id, like.id)
|
Notifier.liked(alice.id, like.author.id, like.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe ".liked limited" do
|
||||||
|
before do
|
||||||
|
@post = FactoryGirl.create(:status_message, author: alice.person, public: false)
|
||||||
|
@like = @post.likes.create!(author: bob.person)
|
||||||
|
@mail = Notifier.liked(alice.id, @like.author.id, @like.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "TO: goes to the right person" do
|
||||||
|
expect(@mail.to).to eq([alice.email])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "BODY: not contains the original post" do
|
||||||
|
expect(@mail.body.encoded).not_to include(@post.message.plain_text)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "BODY: contains the name of person liking" do
|
||||||
|
expect(@mail.body.encoded).to include(@like.author.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should not include translation fallback" do
|
||||||
|
expect(@mail.body.encoded).not_to include(I18n.translate "notifier.a_post_you_shared")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue