diff --git a/Changelog.md b/Changelog.md index 488b0ca9d..a0d4c81e4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/app/helpers/notifier_helper.rb b/app/helpers/notifier_helper.rb index e8f28e0eb..ee62c5a44 100644 --- a/app/helpers/notifier_helper.rb +++ b/app/helpers/notifier_helper.rb @@ -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 diff --git a/app/views/notifier/mentioned.markerb b/app/views/notifier/mentioned.markerb index 9be69b95a..43264d365 100644 --- a/app/views/notifier/mentioned.markerb +++ b/app/views/notifier/mentioned.markerb @@ -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] diff --git a/app/views/notifier/private_message.markerb b/app/views/notifier/private_message.markerb index 0099546d4..b9b6cbd81 100644 --- a/app/views/notifier/private_message.markerb +++ b/app/views/notifier/private_message.markerb @@ -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] diff --git a/spec/helpers/notifier_helper_spec.rb b/spec/helpers/notifier_helper_spec.rb index 1116a18ea..a5e1dc98b 100644 --- a/spec/helpers/notifier_helper_spec.rb +++ b/spec/helpers/notifier_helper_spec.rb @@ -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 diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index baeb4e2ba..7678ca6f3 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -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