Class: Decidim::SpamSignal::Cops::LockCopCommand

Inherits:
CopHandler show all
Defined in:
app/commands/decidim/spam_signal/cops/lock_cop_command.rb

Instance Attribute Summary

Attributes inherited from CopHandler

#admin_reporter, #config, #current_organization, #error_key, #errors, #justification, #reportable, #suspicious_user

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CopHandler

i18n_key, #initialize, #now_tag, #sinalize!

Methods inherited from ApplicationHandler

#config, #handler_name, handler_name, i18n_key

Constructor Details

This class inherits a constructor from Decidim::SpamSignal::Cops::CopHandler

Class Method Details

.formObject



7
8
9
# File 'app/commands/decidim/spam_signal/cops/lock_cop_command.rb', line 7

def self.form
  ::Decidim::SpamSignal::Cops::LockSettingsForm
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/commands/decidim/spam_signal/cops/lock_cop_command.rb', line 11

def call
  errors.add(
    error_key,
    I18n.t("errors.spam",
      scope: "decidim.spam_signal",
      default: "this looks like spam."
    )
  ) unless config['forbid_creation_enabled']
  unless suspicious_user.access_locked?
    hide_comment! if config["hide_comments_enabled"]
    sinalize! if config["sinalize_user_enabled"]
    lock!
  end
  broadcast(config['forbid_creation_enabled'] ? :restore_value : :save)
end