Sha256: 0fc939cbcb58ff049a921d3a1e1f0db212ac47f51b384cb4db9a2013f28cb640

Contents?: true

Size: 927 Bytes

Versions: 4

Compression:

Stored size: 927 Bytes

Contents

# frozen-string_literal: true

module Decidim
  class ResourceHiddenEvent < Decidim::Events::SimpleEvent
    include Decidim::ApplicationHelper

    i18n_attributes :resource_path, :report_reasons, :resource_type, :resource_content

    def resource_path
      @resource.reported_content_url
    end

    def resource_url
      @resource.reported_content_url
    end

    def report_reasons
      extra["report_reasons"].map do |reason|
        I18n.t("decidim.admin.moderations.report.reasons.#{reason}").downcase
      end.join(", ")
    end

    def resource_title
      nil
    end

    def resource_content
      text = translated_attribute(@resource[@resource.reported_attributes.first])

      decidim_sanitize(html_truncate(text, length: 100), strip_tags: true)
    end

    def resource_text
      "<i>#{resource_content}</i>"
    end

    def resource_type
      @resource.model_name.human.downcase
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-admin-0.27.9 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.27.8 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.27.7 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.27.6 app/events/decidim/resource_hidden_event.rb