Commit a87f3139 authored by Dennis Schubert's avatar Dennis Schubert
Browse files

Merge pull request #6679 from svbergerem/post-report-reason-in-mail

Add reason for post report to email sent to admins
parents 0c1483b1 482cbe7f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -114,6 +114,7 @@ Contributions are very welcome, the hard work is done!
* Add white color theme [#6631](https://github.com/diaspora/diaspora/pull/6631)
* Add answer counts to poll [#6641](https://github.com/diaspora/diaspora/pull/6641)
* Check for collapsible posts after images in posts have loaded [#6671](https://github.com/diaspora/diaspora/pull/6671)
* Add reason for post report to email sent to admins [#6679](https://github.com/diaspora/diaspora/pull/6679)

# 0.5.7.0

+8 −6
Original line number Diff line number Diff line
class ReportMailer < ActionMailer::Base
  default from: AppConfig.mail.sender_address

  def self.new_report(type, id)
    Role.moderators.map {|role| super(type, id, role) }
  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

  def new_report(type, id, role)
  def new_report(type, id, reason, role)
    resource = {
      url:    report_index_url,
      type:   I18n.t("notifier.report_email.type.#{type.downcase}"),
      id:   id
      id:     id,
      reason: reason
    }
    person = Person.find(role.person_id)
    return unless person.local?
+1 −1
Original line number Diff line number Diff line
@@ -56,6 +56,6 @@ class Report < ActiveRecord::Base
  end

  def send_report_notification
    Workers::Mail::ReportWorker.perform_async(self.item_type, self.item_id)
    Workers::Mail::ReportWorker.perform_async(id)
  end
end
+5 −2
Original line number Diff line number Diff line
<%= t('notifier.report_email.body', url: resource[:url], type: resource[:type], id: resource[:id]) %>
<%= t("notifier.report_email.body",
      url: resource[:url],
      type: resource[:type],
      id: resource[:id],
      reason: resource[:reason]) %>
+2 −2
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@ module Workers
    class ReportWorker < Base
      sidekiq_options queue: :mail

      def perform(type, id)
        ReportMailer.new_report(type, id).each(&:deliver_now)
      def perform(report_id)
        ReportMailer.new_report(report_id).each(&:deliver_now)
      end
    end
  end
Loading