twitter: don't fail when api key isn't configured.

This commit is contained in:
evazion
2018-09-16 14:04:17 -05:00
parent 325120ee51
commit bd47641601
4 changed files with 21 additions and 14 deletions

View File

@@ -22,6 +22,12 @@ module Sources
false
end
# Should return true if all prerequisites for using the strategy are met.
# Return false if the strategy requires api keys that have not been configured.
def self.enabled?
true
end
# * <tt>url</tt> - Should point to a resource suitable for
# downloading. This may sometimes point to the binary file.
# It may also point to the artist's profile page, in cases

View File

@@ -13,6 +13,10 @@ module Sources::Strategies
urls.compact.any? { |x| x =~ PAGE || x =~ ASSET}
end
def self.enabled?
TwitterService.new.enabled?
end
# https://twitter.com/i/web/status/943446161586733056
# https://twitter.com/motty08111213/status/943446161586733056
def self.status_id_from_url(url)
@@ -135,6 +139,7 @@ module Sources::Strategies
memoize :service
def api_response
return {} if !service.enabled?
service.status(status_id, tweet_mode: "extended")
rescue ::Twitter::Error::NotFound
{}