commit: 3dce6cbbd77bc8b7907f94fd789452d91933877a
parent: 2bcc81700c586a543e849e222c640df89da7fcb0
Author: abcang <abcang1015@gmail.com>
Date: Tue, 21 Nov 2017 04:45:54 +0900
Fixed duplicating URL of photo type of oEmbed (#5763)
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git 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 : ''