Module: Decidim::Ai::SpamDetection
- Includes:
- ActiveSupport::Configurable
- Defined in:
- decidim-ai/app/jobs/decidim/ai/spam_detection/application_job.rb,
decidim-ai/app/jobs/decidim/ai/spam_detection/user_spam_analyzer_job.rb,
decidim-ai/app/jobs/decidim/ai/spam_detection/generic_spam_analyzer_job.rb,
decidim-ai/lib/decidim/ai/spam_detection/service.rb,
decidim-ai/lib/decidim/ai/spam_detection/importer/file.rb,
decidim-ai/lib/decidim/ai/spam_detection/resource/base.rb,
decidim-ai/lib/decidim/ai/spam_detection/strategy/base.rb,
decidim-ai/lib/decidim/ai/spam_detection/spam_detection.rb,
decidim-ai/lib/decidim/ai/spam_detection/strategy/bayes.rb,
decidim-ai/lib/decidim/ai/spam_detection/resource/debate.rb,
decidim-ai/lib/decidim/ai/spam_detection/resource/comment.rb,
decidim-ai/lib/decidim/ai/spam_detection/resource/meeting.rb,
decidim-ai/lib/decidim/ai/spam_detection/importer/database.rb,
decidim-ai/lib/decidim/ai/spam_detection/resource/proposal.rb,
decidim-ai/lib/decidim/ai/spam_detection/resource/initiative.rb,
decidim-ai/lib/decidim/ai/spam_detection/resource/user_base_entity.rb,
decidim-ai/lib/decidim/ai/spam_detection/resource/collaborative_draft.rb
Defined Under Namespace
Modules: Importer, Resource, Strategy Classes: ApplicationJob, GenericSpamAnalyzerJob, Service, UserSpamAnalyzerJob
Class Method Summary collapse
-
.create_reporting_user! ⇒ Object
This method is being called to ensure that user with email configured in ‘Decidim::Ai::SpamDetection.reporting_user_email` variable exists in the database.
-
.resource_classifier ⇒ Object
this is the generic resource classifier class.
-
.resource_registry ⇒ Object
The registry instance that stores the list of strategies needed to process the resources In essence is an enumerator class that responds to ‘register_analyzer(**params)` and `for(name)` methods.
-
.user_classifier ⇒ Object
this is the generic user classifier class.
-
.user_registry ⇒ Object
The registry instance that stores the list of strategies needed to process the user objects In essence is an enumerator class that responds to ‘register_analyzer(**params)` and `for(name)` methods.
Class Method Details
.create_reporting_user! ⇒ Object
This method is being called to ensure that user with email configured in ‘Decidim::Ai::SpamDetection.reporting_user_email` variable exists in the database.
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'decidim-ai/lib/decidim/ai/spam_detection/spam_detection.rb', line 192 def self.create_reporting_user! Decidim::Organization.find_each do |organization| user = organization.users.find_or_initialize_by(email: Decidim::Ai::SpamDetection.reporting_user_email) next if user.persisted? password = SecureRandom.hex(10) user.password = password user.password_confirmation = password user.deleted_at = Time.current user.tos_agreement = true user.name = "" user.skip_confirmation! user.save! end end |
.resource_classifier ⇒ Object
this is the generic resource classifier class. If you need to change your own class, please change the configuration of ‘Decidim::Ai::SpamDetection.detection_service` variable.
164 165 166 167 168 |
# File 'decidim-ai/lib/decidim/ai/spam_detection/spam_detection.rb', line 164 def self.resource_classifier @resource_classifier = Decidim::Ai::SpamDetection.resource_detection_service.safe_constantize&.new( registry: Decidim::Ai::SpamDetection.resource_registry ) end |
.resource_registry ⇒ Object
The registry instance that stores the list of strategies needed to process the resources In essence is an enumerator class that responds to ‘register_analyzer(**params)` and `for(name)` methods
172 173 174 |
# File 'decidim-ai/lib/decidim/ai/spam_detection/spam_detection.rb', line 172 def self.resource_registry @resource_registry ||= Decidim::Ai::StrategyRegistry.new end |
.user_classifier ⇒ Object
this is the generic user classifier class. If you need to change your own class, please change the configuration of ‘Decidim::Ai::SpamDetection.detection_service` variable
178 179 180 181 182 |
# File 'decidim-ai/lib/decidim/ai/spam_detection/spam_detection.rb', line 178 def self.user_classifier @user_classifier = Decidim::Ai::SpamDetection.user_detection_service.safe_constantize&.new( registry: Decidim::Ai::SpamDetection.user_registry ) end |
.user_registry ⇒ Object
The registry instance that stores the list of strategies needed to process the user objects In essence is an enumerator class that responds to ‘register_analyzer(**params)` and `for(name)` methods
186 187 188 |
# File 'decidim-ai/lib/decidim/ai/spam_detection/spam_detection.rb', line 186 def self.user_registry @user_registry ||= Decidim::Ai::StrategyRegistry.new end |