Admin mailer parameterization (#25759)
This commit is contained in:
@ -6,45 +6,52 @@ class AdminMailer < ApplicationMailer
|
||||
helper :accounts
|
||||
helper :languages
|
||||
|
||||
def new_report(recipient, report)
|
||||
@report = report
|
||||
@me = recipient
|
||||
@instance = Rails.configuration.x.local_domain
|
||||
before_action :process_params
|
||||
before_action :set_instance
|
||||
|
||||
default to: -> { @me.user_email }
|
||||
|
||||
def new_report(report)
|
||||
@report = report
|
||||
|
||||
locale_for_account(@me) do
|
||||
mail to: @me.user_email, subject: I18n.t('admin_mailer.new_report.subject', instance: @instance, id: @report.id)
|
||||
mail subject: default_i18n_subject(instance: @instance, id: @report.id)
|
||||
end
|
||||
end
|
||||
|
||||
def new_appeal(recipient, appeal)
|
||||
@appeal = appeal
|
||||
@me = recipient
|
||||
@instance = Rails.configuration.x.local_domain
|
||||
def new_appeal(appeal)
|
||||
@appeal = appeal
|
||||
|
||||
locale_for_account(@me) do
|
||||
mail to: @me.user_email, subject: I18n.t('admin_mailer.new_appeal.subject', instance: @instance, username: @appeal.account.username)
|
||||
mail subject: default_i18n_subject(instance: @instance, username: @appeal.account.username)
|
||||
end
|
||||
end
|
||||
|
||||
def new_pending_account(recipient, user)
|
||||
@account = user.account
|
||||
@me = recipient
|
||||
@instance = Rails.configuration.x.local_domain
|
||||
def new_pending_account(user)
|
||||
@account = user.account
|
||||
|
||||
locale_for_account(@me) do
|
||||
mail to: @me.user_email, subject: I18n.t('admin_mailer.new_pending_account.subject', instance: @instance, username: @account.username)
|
||||
mail subject: default_i18n_subject(instance: @instance, username: @account.username)
|
||||
end
|
||||
end
|
||||
|
||||
def new_trends(recipient, links, tags, statuses)
|
||||
def new_trends(links, tags, statuses)
|
||||
@links = links
|
||||
@tags = tags
|
||||
@statuses = statuses
|
||||
@me = recipient
|
||||
@instance = Rails.configuration.x.local_domain
|
||||
|
||||
locale_for_account(@me) do
|
||||
mail to: @me.user_email, subject: I18n.t('admin_mailer.new_trends.subject', instance: @instance)
|
||||
mail subject: default_i18n_subject(instance: @instance)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def process_params
|
||||
@me = params[:recipient]
|
||||
end
|
||||
|
||||
def set_instance
|
||||
@instance = Rails.configuration.x.local_domain
|
||||
end
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ module Trends
|
||||
return if links_requiring_review.empty? && tags_requiring_review.empty? && statuses_requiring_review.empty?
|
||||
|
||||
User.those_who_can(:manage_taxonomies).includes(:account).find_each do |user|
|
||||
AdminMailer.new_trends(user.account, links_requiring_review, tags_requiring_review, statuses_requiring_review).deliver_later! if user.allows_trends_review_emails?
|
||||
AdminMailer.with(recipient: user.account).new_trends(links_requiring_review, tags_requiring_review, statuses_requiring_review).deliver_later! if user.allows_trends_review_emails?
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -475,7 +475,7 @@ class User < ApplicationRecord
|
||||
User.those_who_can(:manage_users).includes(:account).find_each do |u|
|
||||
next unless u.allows_pending_account_emails?
|
||||
|
||||
AdminMailer.new_pending_account(u.account, self).deliver_later
|
||||
AdminMailer.with(recipient: u.account).new_pending_account(self).deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -23,7 +23,7 @@ class AppealService < BaseService
|
||||
|
||||
def notify_staff!
|
||||
User.those_who_can(:manage_appeals).includes(:account).each do |u|
|
||||
AdminMailer.new_appeal(u.account, @appeal).deliver_later if u.allows_appeal_emails?
|
||||
AdminMailer.with(recipient: u.account).new_appeal(@appeal).deliver_later if u.allows_appeal_emails?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -40,7 +40,7 @@ class ReportService < BaseService
|
||||
|
||||
User.those_who_can(:manage_reports).includes(:account).each do |u|
|
||||
LocalNotificationWorker.perform_async(u.account_id, @report.id, 'Report', 'admin.report')
|
||||
AdminMailer.new_report(u.account, @report).deliver_later if u.allows_report_emails?
|
||||
AdminMailer.with(recipient: u.account).new_report(@report).deliver_later if u.allows_report_emails?
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user