mirror of
				https://github.com/discourse/discourse-ai.git
				synced 2025-10-31 14:38:37 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			681 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			681 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| # frozen_string_literal: true
 | |
| 
 | |
| module DiscourseAi
 | |
|   module NSFW
 | |
|     class EntryPoint
 | |
|       def load_files
 | |
|         require_relative "nsfw_classification"
 | |
|         require_relative "jobs/regular/evaluate_post_uploads"
 | |
|       end
 | |
| 
 | |
|       def inject_into(plugin)
 | |
|         nsfw_detection_cb =
 | |
|           Proc.new do |post|
 | |
|             if SiteSetting.ai_nsfw_detection_enabled &&
 | |
|                  DiscourseAi::NSFW::NSFWClassification.new.can_classify?(post)
 | |
|               Jobs.enqueue(:evaluate_post_uploads, post_id: post.id)
 | |
|             end
 | |
|           end
 | |
| 
 | |
|         plugin.on(:post_created, &nsfw_detection_cb)
 | |
|         plugin.on(:post_edited, &nsfw_detection_cb)
 | |
|       end
 | |
|     end
 | |
|   end
 | |
| end
 |