2023-02-23 09:08:34 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module DiscourseAI
|
|
|
|
module NSFW
|
|
|
|
class EntryPoint
|
2023-02-23 13:50:10 -05:00
|
|
|
def load_files
|
2023-02-24 05:53:43 -05:00
|
|
|
require_relative "evaluation"
|
|
|
|
require_relative "jobs/regular/evaluate_post_uploads"
|
2023-02-23 13:50:10 -05:00
|
|
|
end
|
2023-02-23 09:08:34 -05:00
|
|
|
|
2023-02-23 13:50:10 -05:00
|
|
|
def inject_into(plugin)
|
2023-02-24 05:53:43 -05:00
|
|
|
nsfw_detection_cb =
|
|
|
|
Proc.new do |post|
|
2023-02-24 07:11:58 -05:00
|
|
|
if SiteSetting.ai_nsfw_detection_enabled && post.uploads.present?
|
2023-02-24 05:53:43 -05:00
|
|
|
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)
|
2023-02-23 09:08:34 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|