Class: Decidim::Admin::BulkUnreportUsers

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/admin/bulk_unreport_users.rb

Instance Method Summary collapse

Constructor Details

#initialize(current_user, reportables) ⇒ BulkUnreportUsers

Public: Initializes the command.

current_user - the user that performs the action reportables - all Decidim::Reportable selected by current_user



10
11
12
13
14
# File 'app/commands/decidim/admin/bulk_unreport_users.rb', line 10

def initialize(current_user, reportables)
  @current_user = current_user
  @reportables = reportables
  @result = { ok: [], ko: [] }
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid, together with the resource.

  • :invalid if the resource is not reported

Returns nothing.



22
23
24
25
26
27
28
29
# File 'app/commands/decidim/admin/bulk_unreport_users.rb', line 22

def call
  return broadcast(:invalid) if reportables.blank?

  bulk_unreport_users!
  create_action_log if first_unreported

  broadcast(:ok, **result)
end