diaspora/app/mailers/report_mailer.rb
Lukas Matt 2e36f8d375 Diaspora review part 1
* join the conditions of the inner ifs
* add a uniqueness constraint to the model
* differentiate between author is a local or a remote user
* simplify controller/mailer functions
2014-05-15 07:23:43 -04:00

24 lines
736 B
Ruby

class ReportMailer < ActionMailer::Base
default :from => AppConfig.mail.sender_address
def new_report(type, id)
resource = {
:subject => I18n.t('notifier.report_email.subject', :type => type),
:url => report_index_url,
:type => type,
:id => id
}
Role.admins.each do |role|
resource[:email] = User.find_by_id(role.person_id).email
format(resource).deliver
end
end
private
def format(resource)
mail(to: resource[:email], subject: resource[:subject]) do |format|
format.html { render 'report/report_email', :locals => { :resource => resource } }
format.text { render 'report/report_email', :locals => { :resource => resource } }
end
end
end