2023-02-23 09:08:34 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-03-14 15:03:50 -04:00
|
|
|
module DiscourseAi
|
2023-11-28 23:17:46 -05:00
|
|
|
module Nsfw
|
2023-02-23 09:08:34 -05:00
|
|
|
class EntryPoint
|
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 11:25:02 -05:00
|
|
|
if SiteSetting.ai_nsfw_detection_enabled &&
|
2023-11-28 23:17:46 -05:00
|
|
|
DiscourseAi::Nsfw::Classification.new.can_classify?(post)
|
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
|