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

@@ -65,6 +65,10 @@ module Sources
STACC_PAGE = %r{\A#{WEB}/stacc/#{MONIKER}/?\z}i
NOVEL_PAGE = %r{(?:\Ahttps?://www\.pixiv\.net/novel/show\.php\?id=(\d+))}
def self.enabled?
Danbooru.config.pixiv_login.present? && Danbooru.config.pixiv_password.present?
end
def self.to_dtext(text)
if text.nil?
return nil