async black box

This commit is contained in:
Kyle Drake 2020-11-24 01:11:38 -06:00
parent e4c580564b
commit a2a46d406e
2 changed files with 14 additions and 4 deletions

View file

@ -1781,10 +1781,7 @@ class Site < Sequel::Model
end
if pathname.extname.match(HTML_REGEX) && defined?(BlackBox)
begin
BlackBox.tos_violation_check self, uploaded
rescue
end
BlackBoxWorker.perform_async values[:id], relative_path
end
relative_path_dir = Pathname(relative_path).dirname

View file

@ -0,0 +1,13 @@
class BlackBoxWorker
include Sidekiq::Worker
sidekiq_options queue: :black_box, retry: 10, backtrace: true
def perform(site_id, path)
site = Site[site_id]
return true if site.nil? || site.is_banned? || site.is_deleted
BlackBox.tos_violation_check site, path
end
end
# BlackBox.tos_violation_check self, uploaded