Class: Decidim::SpamDetection::BlockSpamUserCommand

Inherits:
AbstractSpamUserCommand show all
Includes:
Command
Defined in:
lib/decidim/spam_detection/block_spam_user_command.rb

Constant Summary

Constants inherited from AbstractSpamUserCommand

AbstractSpamUserCommand::SPAM_USER

Instance Attribute Summary

Attributes included from Command

#result

Instance Method Summary collapse

Methods included from Command

#errors, #failure?, prepended, #success?

Methods inherited from AbstractSpamUserCommand

#add_spam_detection_metadata!, #create_moderation_admin, #details, #initialize, #moderation_user

Constructor Details

This class inherits a constructor from Decidim::SpamDetection::AbstractSpamUserCommand

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/decidim/spam_detection/block_spam_user_command.rb', line 11

def call
  ActiveRecord::Base.transaction do
    create_user_moderation
    block!
    register_justification!
    notify_user!
    add_spam_detection_metadata!({ "blocked_at" => Time.current, "spam_probability" => @probability })
  end

  Rails.logger.info("User with id #{@user["id"]} was blocked for spam with a probability of #{@probability}%")

  :ok
end