Send an email (to support) when a user is reported for spam
Fix #2839 (closed)
Merge request reports
Activity
Title changed from WIP: Fix 2839 Send an email (to support) when a user is reported for spam to WIP: Fix #2839 (closed) Send an email (to support) when a user is reported for spam
Title changed from WIP: Fix #2839 (closed) Send an email (to support) when a user is reported for spam to WIP: Send an email (to support) when a user is reported for spam
Thanks @jrochkind!
Added 1 commit:
- ae4fbae2 - Send an email (to support) when a user is reported for spam
I don't know why I'm getting a merge conflict reported here -- any tips? I did rebase on master.
This does not yet do "Also add a webhook, if possible" mentioned in #2839 (closed).
But it does do the email abuse report notification feature itself.
I am not sure about the UI, perhaps the admin should be able to opt in or out of receiving these emails? In this MR right now, if admin notification email is set in admin screen, you get the emails.
But it is done and tested with that basic UI. @DouweM
11 11 if @abuse_report.save 12 12 message = "Thank you for your report. A GitLab administrator will look into it shortly." 13 13 redirect_to root_path, notice: message 14 if current_application_settings.admin_notification_email.present? 15 AbuseReportMailer.delay.notify(@abuse_report, current_application_settings.admin_notification_email) 11 11 if @abuse_report.save 12 12 message = "Thank you for your report. A GitLab administrator will look into it shortly." 13 13 redirect_to root_path, notice: message 14 if current_application_settings.admin_notification_email.present? - app/mailers/abuse_report_mailer.rb 0 → 100644
1 class AbuseReportMailer < BaseMailer 2 3 def notify(abuse_report, to_email) 4 @abuse_report = abuse_report 5 6 mail(to: to_email, subject: "[Gitlab] Abuse report filed for `#{@abuse_report.user.username}`") 1 An abuse report was filed on `#{@abuse_report.user.username}` by `#{@abuse_report.reporter.username}`. 47 47 = f.label :version_check_enabled do 48 48 = f.check_box :version_check_enabled 49 49 Version check enabled 50 .form-group 51 = f.label :admin_notification_email, class: 'control-label col-sm-2' 52 .col-sm-10 53 = f.text_field :admin_notification_email, class: 'form-control' 1 require 'spec_helper' 2 3 describe AbuseReportsController do 4 let(:reporter) { create(:user) } 5 let(:user) { create(:user) } 6 let(:message) { "This user is a spammer" } 7 8 before do 9 sign_in(reporter) 10 end 11 12 describe "with admin notification_email set" do 1 require 'spec_helper' 2 3 describe AbuseReportsController do 4 let(:reporter) { create(:user) } 5 let(:user) { create(:user) } 6 let(:message) { "This user is a spammer" } 7 8 before do 9 sign_in(reporter) 10 end 11 12 describe "with admin notification_email set" do 13 let(:admin_email) { "admin@example.com"} 14 before(:example) { allow(current_application_settings).to receive(:admin_notification_email).and_return(admin_email) } 18 abuse_report: { 19 user_id: user.id, 20 message: message 21 } 22 ) 23 24 expect(response).to have_http_status(:redirect) 25 expect(flash[:notice]).to start_with("Thank you for your report") 26 27 email = ActionMailer::Base.deliveries.last 28 29 expect(email).to be_present 30 expect(email.subject).to eq("[Gitlab] Abuse report filed for `#{user.username}`") 31 expect(email.to).to eq([admin_email]) 32 expect(email.body).to include(message) 33 end 9 sign_in(reporter) 10 end 11 12 describe "with admin notification_email set" do 13 let(:admin_email) { "admin@example.com"} 14 before(:example) { allow(current_application_settings).to receive(:admin_notification_email).and_return(admin_email) } 15 16 it "sends a notification email" do 17 post(:create, 18 abuse_report: { 19 user_id: user.id, 20 message: message 21 } 22 ) 23 24 expect(response).to have_http_status(:redirect) mentioned in merge request !1634 (merged)
Replaced by !1634 (merged).
mentioned in commit ba41b2ba
mentioned in commit 955f4248