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.
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'decidim-ai/lib/decidim/ai/spam_detection/spam_detection.rb', line 189 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.
161 162 163 164 165 |
# File 'decidim-ai/lib/decidim/ai/spam_detection/spam_detection.rb', line 161 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
169 170 171 |
# File 'decidim-ai/lib/decidim/ai/spam_detection/spam_detection.rb', line 169 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
175 176 177 178 179 |
# File 'decidim-ai/lib/decidim/ai/spam_detection/spam_detection.rb', line 175 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
183 184 185 |
# File 'decidim-ai/lib/decidim/ai/spam_detection/spam_detection.rb', line 183 def self.user_registry @user_registry ||= Decidim::Ai::StrategyRegistry.new end |