Class: ReportMailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/report_mailer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new_report(report_id) ⇒ Object


4
5
6
7
# File 'app/mailers/report_mailer.rb', line 4

def self.new_report(report_id)
  report = Report.find_by_id(report_id)
  Role.moderators.map {|role| super(report.item_type, report.item_id, report.text, role) }
end

Instance Method Details

#new_report(type, id, reason, role) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/mailers/report_mailer.rb', line 9

def new_report(type, id, reason, role)
  resource = {
    url:    report_index_url,
    type:   I18n.t("notifier.report_email.type.#{type.downcase}"),
    id:     id,
    reason: reason
  }
  person = Person.find(role.person_id)
  return unless person.local?
  user = User.find_by_id(person.owner_id)
  return if user.user_preferences.exists?(email_type: :someone_reported)
  I18n.with_locale(user.language) do
    resource[:email] = user.email
    format(resource)
  end
end