From 3108926dc3844dce6762a9c90e62f62b154ff85c Mon Sep 17 00:00:00 2001 From: Lukas Matt Date: Mon, 23 Jun 2014 15:54:25 -0400 Subject: [PATCH 1/2] Reports email notification; wrong recipient The mailer uses the person_id to find a user which cannot work on a production environment. I haven't used a remote user on my test setup. (cherry picked from commit 01a45ccf40790a8c8b0cc73ed360619047c14447) --- app/mailers/report_mailer.rb | 11 +++++++---- spec/mailers/report_spec.rb | 12 +++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/mailers/report_mailer.rb b/app/mailers/report_mailer.rb index 5438bd9a7..57359cc68 100644 --- a/app/mailers/report_mailer.rb +++ b/app/mailers/report_mailer.rb @@ -8,10 +8,13 @@ class ReportMailer < ActionMailer::Base :id => id } Role.admins.each do |role| - user = User.find_by_id(role.person_id) - unless user.user_preferences.exists?(:email_type => :someone_reported) - resource[:email] = user.email - format(resource).deliver + person = Person.find(role.person_id) + if person.local? + user = User.find_by_id(person.owner_id) + unless user.user_preferences.exists?(:email_type => :someone_reported) + resource[:email] = user.email + format(resource).deliver + end end end end diff --git a/spec/mailers/report_spec.rb b/spec/mailers/report_spec.rb index e5d1b1608..9b41750a5 100644 --- a/spec/mailers/report_spec.rb +++ b/spec/mailers/report_spec.rb @@ -7,12 +7,13 @@ require 'spec_helper' describe Report do describe '#make_notification' do before do - @user = bob - Role.add_admin(@user) + @remote = FactoryGirl.create(:person, :diaspora_handle => "remote@remote.net") + @user = FactoryGirl.create(:user_with_aspect, :username => "local") + Role.add_admin(@user.person) end it "should deliver successfully" do - expect { + expect { ReportMailer.new_report('post', 666) }.to_not raise_error end @@ -22,5 +23,10 @@ describe Report do ReportMailer.new_report('post', 666) }.to change(ActionMailer::Base.deliveries, :size).by(1) end + + it "should include correct recipient" do + ReportMailer.new_report('post', 666) + expect(ActionMailer::Base.deliveries[0].to[0]).to include(@user.email) + end end end From c7536e523a86622357e74ee03b48dd63e6c306ed Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Tue, 24 Jun 2014 22:23:26 +0300 Subject: [PATCH 2/2] Re-bump version to 0.4.0.1 --- Changelog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index a4693905a..4c655fa1c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,7 +2,8 @@ ## Bug fixes -Fix performance regression on stream loading with MySQL/MariaDB database backends [#5014](https://github.com/diaspora/diaspora/issues/5014). +* Fix performance regression on stream loading with MySQL/MariaDB database backends [#5014](https://github.com/diaspora/diaspora/issues/5014) +* Fix issue with post reporting [#5017](https://github.com/diaspora/diaspora/issues/5017) # 0.4.0.0