Sha256: 9a433728cd2ec1a7ab053f045eeae09193742bdee511cf1728d15137e9823240
Contents?: true
Size: 1.22 KB
Versions: 4
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module Decidim module Admin class UnblockUser < Decidim::Command # Public: Initializes the command. # # blocked_user - the user that is unblocked # current_user - the user performing the action def initialize(blocked_user, current_user) @blocked_user = blocked_user @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 @blocked_user.blocked? unblock! broadcast(:ok, @blocked_user) end private def unblock! Decidim.traceability.perform_action!( "unblock", @blocked_user, @current_user, extra: { reportable_type: @blocked_user.class.name } ) do @blocked_user.blocked = false @blocked_user.blocked_at = nil @blocked_user.block_id = nil @blocked_user.name = @blocked_user.user_name @blocked_user.save! end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems