Module: Decidim::Ai::SpamDetection
- Defined in:
- lib/decidim/ai/spam_detection/service.rb,
lib/decidim/ai/spam_detection/importer/file.rb,
lib/decidim/ai/spam_detection/resource/base.rb,
lib/decidim/ai/spam_detection/strategy/base.rb,
lib/decidim/ai/spam_detection/spam_detection.rb,
lib/decidim/ai/spam_detection/strategy/bayes.rb,
lib/decidim/ai/spam_detection/resource/debate.rb,
lib/decidim/ai/spam_detection/resource/comment.rb,
lib/decidim/ai/spam_detection/resource/meeting.rb,
lib/decidim/ai/spam_detection/importer/database.rb,
lib/decidim/ai/spam_detection/resource/proposal.rb,
lib/decidim/ai/spam_detection/resource/initiative.rb,
app/jobs/decidim/ai/spam_detection/application_job.rb,
lib/decidim/ai/spam_detection/resource/user_base_entity.rb,
app/jobs/decidim/ai/spam_detection/user_spam_analyzer_job.rb,
app/jobs/decidim/ai/spam_detection/generic_spam_analyzer_job.rb
Defined Under Namespace
Modules: Importer, Resource, Strategy Classes: ApplicationJob, GenericSpamAnalyzerJob, Service, UserSpamAnalyzerJob
Class Method Summary collapse
- .config ⇒ Object
- .configure {|_self| ... } ⇒ Object
-
.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
.config ⇒ Object
29 |
# File 'lib/decidim/ai/spam_detection/spam_detection.rb', line 29 def config = self |
.configure {|_self| ... } ⇒ Object
31 32 33 |
# File 'lib/decidim/ai/spam_detection/spam_detection.rb', line 31 def configure yield self end |
.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.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/decidim/ai/spam_detection/spam_detection.rb', line 173 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.
145 146 147 148 149 |
# File 'lib/decidim/ai/spam_detection/spam_detection.rb', line 145 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
153 154 155 |
# File 'lib/decidim/ai/spam_detection/spam_detection.rb', line 153 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
159 160 161 162 163 |
# File 'lib/decidim/ai/spam_detection/spam_detection.rb', line 159 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
167 168 169 |
# File 'lib/decidim/ai/spam_detection/spam_detection.rb', line 167 def self.user_registry @user_registry ||= Decidim::Ai::StrategyRegistry.new end |