Sha256: cf0fc7e93d390e1814bc839b048d1f5126eefb1f338a2f5a5b7f6a459d659bd5

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

module Decidim
  # A custom mailer for sending notifications to an admin when a report is created..
  class ReportedMailer < Decidim::ApplicationMailer
    helper Decidim::ResourceHelper

    helper_method :reported_content_url, :manage_moderations_url

    def report(user, report)
      with_user(user) do
        @report = report
        @participatory_process = @report.moderation.participatory_process
        @organization = user.organization
        @user = user
        subject = I18n.t("report.subject", scope: "decidim.reported_mailer")
        mail(to: user.email, subject: subject)
      end
    end

    def hide(user, report)
      with_user(user) do
        @report = report
        @participatory_process = @report.moderation.participatory_process
        @organization = user.organization
        @user = user
        subject = I18n.t("hide.subject", scope: "decidim.reported_mailer")
        mail(to: user.email, subject: subject)
      end
    end

    private

    def reported_content_url
      @reported_content_url ||= @report.moderation.reportable.reported_content_url
    end

    def manage_moderations_url
      @manage_moderations_url ||= decidim_admin.moderations_url(@participatory_process.id, host: @organization.host)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
decidim-core-0.5.1 app/mailers/decidim/reported_mailer.rb
decidim-0.5.1 decidim-core/app/mailers/decidim/reported_mailer.rb
decidim-core-0.5.0 app/mailers/decidim/reported_mailer.rb
decidim-0.5.0 decidim-core/app/mailers/decidim/reported_mailer.rb