Sha256: 4b056dad5945ecd73fae1c689d04d7555159c53884cb9967a3b05551b6698ee7
Contents?: true
Size: 1.23 KB
Versions: 21
Compression:
Stored size: 1.23 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.extended_data["user_name"] @blocked_user.save! end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems
Version | Path |
---|---|
decidim-admin-0.27.2 | app/commands/decidim/admin/unblock_user.rb |