From 4e409e629d2f5a2d981f9501ed7e65c647a1c399 Mon Sep 17 00:00:00 2001 From: abcang Date: Tue, 21 Nov 2017 04:45:54 +0900 Subject: [PATCH] Fixed duplicating URL of photo type of oEmbed (#5763) --- app/services/fetch_link_card_service.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index 14c21b6ccf..37cf75379f 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -74,6 +74,9 @@ class FetchLinkCardService < BaseService return false unless response.respond_to?(:type) + # The photo will change the URL. So, to avoid duplication of URLs, PreviewCard needs to be checked again. + @card = PreviewCard.find_by(url: response.url) || @card if response.type == 'photo' + @card.type = response.type @card.title = response.respond_to?(:title) ? response.title : '' @card.author_name = response.respond_to?(:author_name) ? response.author_name : ''