2023-02-23 12:25:00 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# frozen_string_literal: true
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-14 16:03:50 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								module DiscourseAi
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-23 12:25:00 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  module Toxicity
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    class EntryPoint
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-23 15:50:10 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      def load_files
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-24 07:53:43 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        require_relative "scan_queue"
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-24 13:25:02 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        require_relative "toxicity_classification"
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-23 12:25:00 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-24 07:53:43 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        require_relative "jobs/regular/toxicity_classify_post"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        require_relative "jobs/regular/toxicity_classify_chat_message"
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-23 15:50:10 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      end
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-23 12:25:00 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-23 15:50:10 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      def inject_into(plugin)
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-14 16:03:50 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        post_analysis_cb = Proc.new { |post| DiscourseAi::Toxicity::ScanQueue.enqueue_post(post) }
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-23 12:25:00 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-24 07:53:43 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        plugin.on(:post_created, &post_analysis_cb)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        plugin.on(:post_edited, &post_analysis_cb)
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-23 12:25:00 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-24 07:53:43 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        chat_message_analysis_cb =
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-14 16:03:50 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          Proc.new { |message| DiscourseAi::Toxicity::ScanQueue.enqueue_chat_message(message) }
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-23 12:25:00 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-24 07:53:43 -03:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        plugin.on(:chat_message_created, &chat_message_analysis_cb)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        plugin.on(:chat_message_edited, &chat_message_analysis_cb)
							 | 
						
					
						
							
								
									
										
										
										
											2023-02-23 12:25:00 -03:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  end
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								end
							 |