diff --git a/Changelog.md b/Changelog.md index c1a45a409..a5a4a4964 100644 --- a/Changelog.md +++ b/Changelog.md @@ -31,6 +31,7 @@ * Support syntax highlighting for fenced code blocks [#5908](https://github.com/diaspora/diaspora/pull/5908) * Added link to diasporafoundation.org to invitation email [#5893](https://github.com/diaspora/diaspora/pull/5893) * Gracefully handle missing `og:url`s [#5926](https://github.com/diaspora/diaspora/pull/5926) +* Remove private post content from "also commented" mails [#5931](https://github.com/diaspora/diaspora/pull/5931) # 0.5.0.1 diff --git a/app/mailers/notification_mailers/also_commented.rb b/app/mailers/notification_mailers/also_commented.rb index d5ef2d3f4..15914d25a 100644 --- a/app/mailers/notification_mailers/also_commented.rb +++ b/app/mailers/notification_mailers/also_commented.rb @@ -8,7 +8,11 @@ module NotificationMailers if mail? @headers[:from] = "\"#{@comment.author_name} (diaspora*)\" <#{AppConfig.mail.sender_address}>" - @headers[:subject] = "Re: #{@comment.comment_email_subject}" + if @comment.public? + @headers[:subject] = "Re: #{@comment.comment_email_subject}" + else + @headers[:subject] = I18n.t("notifier.also_commented.limited_subject") + end end end diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index abc93b6dc..80aa03b49 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -754,8 +754,10 @@ en: sharing: "has started sharing with you!" view_profile: "View %{name}’s profile" comment_on_post: - limited_subject: "There's a new comment on a post you commented" + limited_subject: "There's a new comment on one of your posts" reply: "Reply or view %{name}’s post >" + also_commented: + limited_subject: "There's a new comment on a post you commented" mentioned: subject: "%{name} has mentioned you on diaspora*" mentioned: "mentioned you in a post:" diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index 2b37d1a95..7ba777de8 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -1,14 +1,14 @@ -require 'spec_helper' +require "spec_helper" -describe Notifier, :type => :mailer do +describe Notifier, type: :mailer do let(:person) { FactoryGirl.create(:person) } before do Notifier.deliveries = [] end - describe '.administrative' do - it 'mails a user' do + describe ".administrative" do + it "mails a user" do mails = Notifier.admin("Welcome to bureaucracy!", [bob]) expect(mails.length).to eq(1) mail = mails.first @@ -17,48 +17,50 @@ describe Notifier, :type => :mailer do expect(mail.body.encoded).to match /#{bob.username}/ end - context 'mails a bunch of users' do + context "mails a bunch of users" do before do @users = [] 5.times do @users << FactoryGirl.create(:user) end end - it 'has a body' do + it "has a body" do mails = Notifier.admin("Welcome to bureaucracy!", @users) expect(mails.length).to eq(5) - mails.each{|mail| - this_user = @users.detect{|u| mail.to == [u.email]} + mails.each {|mail| + this_user = @users.find {|u| mail.to == [u.email] } expect(mail.body.encoded).to match /Welcome to bureaucracy!/ expect(mail.body.encoded).to match /#{this_user.username}/ } end it "has attachments" do - mails = Notifier.admin("Welcome to bureaucracy!", @users, :attachments => [{:name => "retention stats", :file => "here is some file content"}]) + mails = Notifier.admin("Welcome to bureaucracy!", @users, + attachments: [{name: "retention stats", file: "here is some file content"}]) expect(mails.length).to eq(5) - mails.each{|mail| + mails.each {|mail| expect(mail.attachments.count).to eq(1) } end end end - describe '.single_admin' do - it 'mails a user' do + describe ".single_admin" do + it "mails a user" do mail = Notifier.single_admin("Welcome to bureaucracy!", bob) expect(mail.to).to eq([bob.email]) expect(mail.body.encoded).to match /Welcome to bureaucracy!/ expect(mail.body.encoded).to match /#{bob.username}/ end - it 'has the layout' do + it "has the layout" do mail = Notifier.single_admin("Welcome to bureaucracy!", bob) expect(mail.body.encoded).to match /change your notification settings/ end - it 'has an optional attachment' do - mail = Notifier.single_admin("Welcome to bureaucracy!", bob, :attachments => [{:name => "retention stats", :file => "here is some file content"}]) + it "has an optional attachment" do + mail = Notifier.single_admin("Welcome to bureaucracy!", bob, + attachments: [{name: "retention stats", file: "here is some file content"}]) expect(mail.attachments.length).to eq(1) end end @@ -66,15 +68,15 @@ describe Notifier, :type => :mailer do describe ".started_sharing" do let!(:request_mail) { Notifier.started_sharing(bob.id, person.id) } - it 'goes to the right person' do + it "goes to the right person" do expect(request_mail.to).to eq([bob.email]) end - it 'has the name of person sending the request' do + it "has the name of person sending the request" do expect(request_mail.body.encoded.include?(person.name)).to be true end - it 'has the css' do + it "has the css" do request_mail.body.encoded.include?("