Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrealtin <juliakbln@gmail.com>2015-08-25 13:43:56 +0300
committerJonne Haß <me@jhass.eu>2015-09-07 13:31:25 +0300
commit15b186518c47665f3765bf175aa9f94068f05e8c (patch)
tree0b69e80489178aca6073fc1623b8a1e0b692adf5 /app/mailers
parent098c30c2b7dbfd6138de591b3ca379cb4ef9d87e (diff)
add moderators to report email recievers
and refactor coding style according to pull request comments (#5324)
Diffstat (limited to 'app/mailers')
-rw-r--r--app/mailers/report_mailer.rb42
1 files changed, 22 insertions, 20 deletions
diff --git a/app/mailers/report_mailer.rb b/app/mailers/report_mailer.rb
index b3479cc74..35aafcf3e 100644
--- a/app/mailers/report_mailer.rb
+++ b/app/mailers/report_mailer.rb
@@ -1,30 +1,32 @@
class ReportMailer < ActionMailer::Base
- default :from => AppConfig.mail.sender_address
+ default from: AppConfig.mail.sender_address
- def new_report(type, id)
+ def self.new_report(type, id)
+ Role.moderators.map {|role| super(type, id, role) }
+ end
+
+ def new_report(type, id, role)
resource = {
- :url => report_index_url,
- :type => I18n.t('notifier.report_email.type.' + type),
- :id => id
+ url: report_index_url,
+ type: I18n.t("notifier.report_email.type." + type),
+ id: id
}
-
- Role.admins.each do |role|
- person = Person.find(role.person_id)
- if person.local?
- user = User.find_by_id(person.owner_id)
- unless user.user_preferences.exists?(:email_type => :someone_reported)
- resource[:email] = user.email
- format(resource)
- end
- end
+ 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
private
- def format(resource)
- mail(to: resource[:email], subject: I18n.t('notifier.report_email.subject', :type => resource[:type])) do |format|
- format.html { render 'report/report_email', :locals => { :resource => resource } }
- format.text { render 'report/report_email', :locals => { :resource => resource } }
- end
+
+ def format(resource)
+ mail(to: resource[:email], subject: I18n.t("notifier.report_email.subject", type: resource[:type])) do |format|
+ format.html { render "report/report_email", locals: {resource: resource} }
+ format.text { render "report/report_email", locals: {resource: resource} }
end
+ end
end