From a2a46d406e9f274d15e746d9bffb980eff5b26bb Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Tue, 24 Nov 2020 01:11:38 -0600 Subject: [PATCH] async black box --- models/site.rb | 5 +---- workers/black_box_worker.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 workers/black_box_worker.rb diff --git a/models/site.rb b/models/site.rb index 7156a36b..cb3e14a1 100644 --- a/models/site.rb +++ b/models/site.rb @@ -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 diff --git a/workers/black_box_worker.rb b/workers/black_box_worker.rb new file mode 100644 index 00000000..37eccb48 --- /dev/null +++ b/workers/black_box_worker.rb @@ -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 \ No newline at end of file