Don't truncate notification emails anymore, close #4342
This commit is contained in:
parent
47cba24cf8
commit
46223a2dfc
6 changed files with 12 additions and 33 deletions
|
|
@ -142,6 +142,7 @@ diaspora.yml file**. The existing settings from 0.4.x and before will not work a
|
|||
* Allow to set unhosted button and currency for paypal donation [#5452](https://github.com/diaspora/diaspora/pull/5452)
|
||||
* Add followed tags in the mobile menu [#5468](https://github.com/diaspora/diaspora/pull/5468)
|
||||
* Replace Pagedown with markdown-it [#5526](https://github.com/diaspora/diaspora/pull/5526)
|
||||
* Do not truncate notification emails anymore [#4342](https://github.com/diaspora/diaspora/issues/4342)
|
||||
|
||||
# 0.4.1.2
|
||||
|
||||
|
|
|
|||
|
|
@ -2,23 +2,22 @@ module NotifierHelper
|
|||
|
||||
# @param post [Post] The post object.
|
||||
# @param opts [Hash] Optional hash. Accepts :length parameters.
|
||||
# @return [String] The truncated and formatted post.
|
||||
# @return [String] The formatted post.
|
||||
def post_message(post, opts={})
|
||||
if !post.public?
|
||||
I18n.translate 'notifier.a_private_message'
|
||||
elsif post.respond_to? :message
|
||||
post.message.plain_text_without_markdown truncate: opts.fetch(:length, 200)
|
||||
post.message.plain_text_without_markdown
|
||||
else
|
||||
I18n.translate 'notifier.a_post_you_shared'
|
||||
end
|
||||
end
|
||||
|
||||
# @param comment [Comment] The comment to process.
|
||||
# @param opts [Hash] Optional hash. Accepts :length parameters.
|
||||
# @return [String] The truncated and formatted comment.
|
||||
# @return [String] The formatted comment.
|
||||
def comment_message(comment, opts={})
|
||||
if comment.post.public?
|
||||
comment.message.plain_text_without_markdown truncate: opts.fetch(:length, 600)
|
||||
comment.message.plain_text_without_markdown
|
||||
else
|
||||
I18n.translate 'notifier.a_limited_post_comment'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<%= post_message(@notification.post, :process_newlines => true, :length => 600) %>
|
||||
<%= post_message(@notification.post, :process_newlines => true) %>
|
||||
|
||||
[<%= t('notifier.comment_on_post.reply', :name => @notification.post_author_name) %>][1]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<%= post_message(@notification.message, :process_newlines => true, :length => 2000) %>
|
||||
<%= post_message(@notification.message, :process_newlines => true) %>
|
||||
|
||||
[<%= t('.reply_to_or_view') %>][1]
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ require 'spec_helper'
|
|||
describe NotifierHelper, :type => :helper do
|
||||
describe '#post_message' do
|
||||
before do
|
||||
# post for truncate test
|
||||
@post = FactoryGirl.create(:status_message, text: "hi dude! "*10, public: true)
|
||||
@truncated_post = "hi dude! hi dude! hi dude! hi dude! hi dude! hi dude! hi dude! hi dude! hi du..."
|
||||
# post for markdown test
|
||||
@markdown_post = FactoryGirl.create(:status_message,
|
||||
text: "[link](http://diasporafoundation.org) **bold text** *other text*", public: true)
|
||||
|
|
@ -17,15 +14,9 @@ describe NotifierHelper, :type => :helper do
|
|||
|
||||
@limited_post = FactoryGirl.create(:status_message, text: "This is top secret post. Shhhhhhhh!!!", public: false)
|
||||
end
|
||||
|
||||
it 'truncates in the post' do
|
||||
opts = {:length => @post.text.length - 10}
|
||||
expect(post_message(@post, opts)).to eq(@truncated_post)
|
||||
end
|
||||
|
||||
|
||||
it 'strip markdown in the post' do
|
||||
opts = {:length => @markdown_post.text.length}
|
||||
expect(post_message(@markdown_post, opts)).to eq(@striped_markdown_post)
|
||||
expect(post_message(@markdown_post)).to eq(@striped_markdown_post)
|
||||
end
|
||||
|
||||
it 'hides the private content' do
|
||||
|
|
@ -35,12 +26,6 @@ describe NotifierHelper, :type => :helper do
|
|||
|
||||
describe '#comment_message' do
|
||||
before do
|
||||
# comment for truncate test
|
||||
@comment = FactoryGirl.create(:comment)
|
||||
@comment.text = "hi dude! "*10
|
||||
@comment.post.public = true
|
||||
@truncated_comment = "hi dude! hi dude! hi dude! hi dude! hi dude! hi dude! hi dude! hi dude! hi d..."
|
||||
|
||||
# comment for markdown test
|
||||
@markdown_comment = FactoryGirl.create(:comment)
|
||||
@markdown_comment.post.public = true
|
||||
|
|
@ -52,15 +37,9 @@ describe NotifierHelper, :type => :helper do
|
|||
@limited_comment.post.public = false
|
||||
@limited_comment.text = "This is top secret comment. Shhhhhhhh!!!"
|
||||
end
|
||||
|
||||
it 'truncates in the comment' do
|
||||
opts = {:length => @comment.text.length - 10}
|
||||
expect(comment_message(@comment, opts)).to eq(@truncated_comment)
|
||||
end
|
||||
|
||||
|
||||
it 'strip markdown in the comment' do
|
||||
opts = {:length => @markdown_comment.text.length}
|
||||
expect(comment_message(@markdown_comment, opts)).to eq(@striped_markdown_comment)
|
||||
expect(comment_message(@markdown_comment)).to eq(@striped_markdown_comment)
|
||||
end
|
||||
|
||||
it 'hides the private content' do
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ describe Notifier, :type => :mailer do
|
|||
expect(@mail.to).to eq([alice.email])
|
||||
end
|
||||
|
||||
it 'BODY: contains the truncated original post' do
|
||||
it 'BODY: contains the original post' do
|
||||
expect(@mail.body.encoded).to include(@post.message.plain_text)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue