Class: Decidim::SpamDetection::ReportSpamUserCommand

Inherits:
AbstractSpamUserCommand show all
Includes:
Command
Defined in:
lib/decidim/spam_detection/report_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, #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
# File 'lib/decidim/spam_detection/report_spam_user_command.rb', line 11

def call
  ActiveRecord::Base.transaction do
    find_or_create_moderation!
    create_report!
    update_report_count!
    add_spam_detection_metadata!({ "reported_at" => Time.current, "spam_probability" => @probability })
  end

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

  :ok
end