Sha256: 2a68ec4a334ad16e0280ffd007fdf2aaa05a8ba1e7db705fa9d1cac983d97d47
Contents?: true
Size: 1.16 KB
Versions: 21
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module Decidim module Admin # A command with all the business logic when a user unreports a resource. class UnreportResource < Rectify::Command # Public: Initializes the command. # # reportable - A Decidim::Reportable # current_user - the user performing the action def initialize(reportable, current_user) @reportable = reportable @current_user = current_user end # Executes the command. Broadcasts these events: # # - :ok when everything is valid, together with the resource. # - :invalid if the resource is not reported # # Returns nothing. def call return broadcast(:invalid) unless @reportable.reported? unreport! broadcast(:ok, @reportable) end private def unreport! Decidim.traceability.perform_action!( "unreport", @reportable.moderation, @current_user, extra: { reportable_type: @reportable.class.name } ) do @reportable.moderation.update!(report_count: 0, hidden_at: nil) end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems