This commit is contained in:
@ -17,6 +17,9 @@ class Api::V1::ReportsController < Api::BaseController
|
||||
status_ids: reported_status_ids,
|
||||
comment: report_params[:comment]
|
||||
)
|
||||
|
||||
User.admins.includes(:account).each { |u| AdminMailer.new_report(u.account, @report).deliver_later }
|
||||
|
||||
render :show
|
||||
end
|
||||
|
||||
|
13
app/mailers/admin_mailer.rb
Normal file
13
app/mailers/admin_mailer.rb
Normal file
@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AdminMailer < ApplicationMailer
|
||||
def new_report(recipient, report)
|
||||
@report = report
|
||||
@me = recipient
|
||||
@instance = Rails.configuration.x.local_domain
|
||||
|
||||
locale_for_account(@me) do
|
||||
mail to: @me.user_email, subject: I18n.t('admin_mailer.new_report.subject', instance: @instance, id: @report.id)
|
||||
end
|
||||
end
|
||||
end
|
@ -4,4 +4,12 @@ class ApplicationMailer < ActionMailer::Base
|
||||
default from: ENV.fetch('SMTP_FROM_ADDRESS') { 'notifications@localhost' }
|
||||
layout 'mailer'
|
||||
helper :instance
|
||||
|
||||
protected
|
||||
|
||||
def locale_for_account(account)
|
||||
I18n.with_locale(account.user_locale || I18n.default_locale) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -67,12 +67,4 @@ class NotificationMailer < ApplicationMailer
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def locale_for_account(account)
|
||||
I18n.with_locale(account.user_locale || I18n.default_locale) do
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
5
app/views/admin_mailer/new_report.text.erb
Normal file
5
app/views/admin_mailer/new_report.text.erb
Normal file
@ -0,0 +1,5 @@
|
||||
<%= display_name(@me) %>,
|
||||
|
||||
<%= raw t('admin_mailer.new_report.body', target: @report.target_account.acct, reporter: @report.account.acct) %>
|
||||
|
||||
<%= raw t('application_mailer.view')%> <%= admin_report_url(@report) %>
|
Reference in New Issue
Block a user