Sha256: 6189e1d6cb5ff6198fe42ef088a67b76b35d23b54543f9628c80e45ddb5081c3
Contents?: true
Size: 1.15 KB
Versions: 25
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Decidim module Admin class UnreportUser < Decidim::Command # Public: Initializes the command. # # reportable - A Decidim::User - The user reported # 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.user_moderation, @current_user, extra: { reportable_type: @reportable.class.name, username: @reportable.name, user_id: @reportable.id } ) do @reportable.user_moderation.destroy! end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems