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

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