Sha256: 2c62ff00c3c10a3d275885cbf272ea0973bf62a82663ab5af33c0c13c92a804c

Contents?: true

Size: 715 Bytes

Versions: 4

Compression:

Stored size: 715 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    module HideResourceOverride
      extend ActiveSupport::Concern

      included do
        def call
          return broadcast(:invalid) unless hideable?

          hide!

          send_hide_notification_to_author
          send_hide_email_to_author

          broadcast(:ok, @reportable)
        end

        private

        def send_hide_email_to_author
          Decidim::Admin::HiddenResourceMailer.notify_mail(
            @reportable, resource_authors, report_reasons
          ).deliver_later
        end

        def resource_authors
          @reportable.try(:authors) || [@reportable.try(:author)]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-reporting_proposals-0.5.2 app/commands/concerns/decidim/admin/hide_resource_override.rb
decidim-reporting_proposals-0.5.1 app/commands/concerns/decidim/admin/hide_resource_override.rb
decidim-reporting_proposals-0.5.0 app/commands/concerns/decidim/admin/hide_resource_override.rb
decidim-reporting_proposals-0.4.2 app/commands/concerns/decidim/admin/hide_resource_override.rb