diff --git a/app/logical/upload_service/preprocessor.rb b/app/logical/upload_service/preprocessor.rb index a90444df5..c9d397299 100644 --- a/app/logical/upload_service/preprocessor.rb +++ b/app/logical/upload_service/preprocessor.rb @@ -2,10 +2,9 @@ class UploadService class Preprocessor extend Memoist - attr_reader :params, :original_post_id + attr_reader :params def initialize(params) - @original_post_id = params.delete(:original_post_id) || -1 @params = params end @@ -21,17 +20,6 @@ class UploadService params[:referer_url] end - def strategy - Sources::Strategies.find(source, referer_url) - end - memoize :strategy - - # When searching posts we have to use the canonical source - def canonical_source - strategy.canonical_url - end - memoize :canonical_source - def in_progress? if md5.present? Upload.exists?(status: "preprocessing", md5: md5) @@ -62,8 +50,6 @@ class UploadService end def start! - raise NotImplementedError, "No login credentials configured for #{strategy.site_name}." unless strategy.class.enabled? - params[:rating] ||= "q" params[:tag_string] ||= "tagme" upload = Upload.create!(params) @@ -72,7 +58,7 @@ class UploadService upload.update(status: "preprocessing") file = Utils.get_file_for_upload(upload.source_url, upload.referer_url, params[:file]&.tempfile) - Utils.process_file(upload, file, original_post_id: original_post_id) + Utils.process_file(upload, file) upload.rating = params[:rating] upload.tag_string = params[:tag_string] diff --git a/app/logical/upload_service/utils.rb b/app/logical/upload_service/utils.rb index 1092f70f9..8e57127f5 100644 --- a/app/logical/upload_service/utils.rb +++ b/app/logical/upload_service/utils.rb @@ -6,7 +6,7 @@ class UploadService source =~ %r{\Ahttps?://} end - def process_file(upload, file, original_post_id: nil) + def process_file(upload, file) media_file = MediaFile.open(file) upload.file = media_file diff --git a/test/unit/upload_service_test.rb b/test/unit/upload_service_test.rb index aa86d5a80..e8226b851 100644 --- a/test/unit/upload_service_test.rb +++ b/test/unit/upload_service_test.rb @@ -28,12 +28,6 @@ class UploadServiceTest < ActiveSupport::TestCase @upload = FactoryBot.build(:jpg_upload) end - context "with an original_post_id" do - should "run" do - UploadService::Utils.process_file(@upload, @upload.file.tempfile, original_post_id: 12345) - end - end - should "run" do UploadService::Utils.process_file(@upload, @upload.file.tempfile) assert_equal("jpg", @upload.file_ext) @@ -723,7 +717,7 @@ class UploadServiceTest < ActiveSupport::TestCase assert_equal(true, upload.valid?) assert_equal("s", upload.rating) - assert_equal("rating:safe blah ", upload.tag_string) + assert_equal("rating:safe blah", upload.tag_string) assert_equal("s", upload.post.rating) assert_equal("blah", upload.post.tag_string)