Class: Decidim::Verifications::RevokeAuthorizationsByCondition

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/verifications/revoke_authorizations_by_condition.rb

Overview

A command to revoke authorizations with filter

Instance Method Summary collapse

Constructor Details

#initialize(organization, form) ⇒ RevokeAuthorizationsByCondition

Initializes the command.

Parameters:

  • organization (Decidim::Organization)

    The organization where authorizations will be revoked

  • form (Decidim::Verifications::RevocationsBeforeDateForm)

    A form object with the verification data to confirm it



12
13
14
15
# File 'app/commands/decidim/verifications/revoke_authorizations_by_condition.rb', line 12

def initialize(organization, form)
  @organization = organization
  @form = form
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if the handler was not valid and we could not proceed.

Returns nothing.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/commands/decidim/verifications/revoke_authorizations_by_condition.rb', line 23

def call
  return broadcast(:invalid) unless @organization
  return broadcast(:invalid) unless @form.valid?

  if @form.before_date.present?
    RevokeAuthorizationsByConditionJob.perform_later(
      organization,
      current_user,
      @form.before_date,
      @form.impersonated_only?
    )

    broadcast(:ok)
  else
    broadcast(:invalid)
  end
end