Uploads: Check if strategy is enabled before use
Avoid returning bare API tracebacks from pixiv et al when login details are not configured, and instead raise a generic error.
This commit is contained in:
@@ -64,6 +64,8 @@ class UploadService
|
||||
end
|
||||
|
||||
def start!
|
||||
raise NotImplementedError, "No login credentials configured for #{strategy.site_name}." unless strategy.class.enabled?
|
||||
|
||||
if Utils.is_downloadable?(source)
|
||||
if Post.system_tag_match("source:#{canonical_source}").where.not(id: original_post_id).exists?
|
||||
raise ActiveRecord::RecordNotUnique, "A post with source #{canonical_source} already exists"
|
||||
|
||||
@@ -72,6 +72,8 @@ class UploadService
|
||||
raise "No file or source URL provided" if upload.source_url.blank?
|
||||
|
||||
strategy = Sources::Strategies.find(upload.source_url, upload.referer_url)
|
||||
raise NotImplementedError, "No login credentials configured for #{strategy.site_name}." unless strategy.class.enabled?
|
||||
|
||||
file = strategy.download_file!
|
||||
|
||||
if strategy.data[:ugoira_frame_data].present?
|
||||
|
||||
Reference in New Issue
Block a user