about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRenato "Lond" Cerqueira <renato@lond.com.br>2017-12-12 15:12:09 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-12-12 15:12:09 +0100
commit19257d91bf1e613b48a7ac9de7ce6933405c9657 (patch)
treed7f0a06a37b900e32d3f13096dbc511733bdf7bf
parentfe180f18ff38a01007842ccff293a84a63336aae (diff)
Return false if object does not respond to url (#5988)
Avoid error when the service returns a mostly valid oembed, but has no
url in it, causing a MethodError: undefined method `url'
for #<OEmbed::Response::Photo:0x000056505def9620>
-rw-r--r--app/services/fetch_link_card_service.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb
index 7f4518ea7..9f0c73858 100644
--- a/app/services/fetch_link_card_service.rb
+++ b/app/services/fetch_link_card_service.rb
@@ -87,6 +87,7 @@ class FetchLinkCardService < BaseService
     when 'link'
       @card.image = URI.parse(response.thumbnail_url) if response.respond_to?(:thumbnail_url)
     when 'photo'
+      return false unless response.respond_to?(:url)
       @card.embed_url = response.url
       @card.width     = response.width.presence  || 0
       @card.height    = response.height.presence || 0