1
0
mirror of https://github.com/funamitech/mastodon synced 2024-12-18 16:48:37 +09:00

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>
This commit is contained in:
Renato "Lond" Cerqueira 2017-12-12 15:12:09 +01:00 committed by Eugen Rochko
parent fe180f18ff
commit 19257d91bf

View File

@ -87,6 +87,7 @@ class FetchLinkCardService < BaseService
when 'link' when 'link'
@card.image = URI.parse(response.thumbnail_url) if response.respond_to?(:thumbnail_url) @card.image = URI.parse(response.thumbnail_url) if response.respond_to?(:thumbnail_url)
when 'photo' when 'photo'
return false unless response.respond_to?(:url)
@card.embed_url = response.url @card.embed_url = response.url
@card.width = response.width.presence || 0 @card.width = response.width.presence || 0
@card.height = response.height.presence || 0 @card.height = response.height.presence || 0