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:
nonamethanks
2020-07-11 03:14:06 +02:00
parent 42f0112c38
commit 3179509791
7 changed files with 24 additions and 0 deletions

View File

@@ -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?