about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorabcang <abcang1015@gmail.com>2017-11-21 04:45:54 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-11-20 20:45:54 +0100
commit3dce6cbbd77bc8b7907f94fd789452d91933877a (patch)
treef034e4ef85612b6b7f3beb965e81a5efb2589842 /app/services
parent2bcc81700c586a543e849e222c640df89da7fcb0 (diff)
Fixed duplicating URL of photo type of oEmbed (#5763)
Diffstat (limited to 'app/services')
-rw-r--r--app/services/fetch_link_card_service.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb
index 14c21b6cc..37cf75379 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   : ''