about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2017-05-18 22:43:10 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-05-18 15:43:10 +0200
commit79ef8b3653a6ff7edbc1af0741dff36522262c07 (patch)
tree161a1bec18bed8475ae780dd8e28344d0dcfbb1d /app/services
parentb11c4326d289d8b0307f5d1466171ac147a07767 (diff)
Fetch remote image using http.rb (#3114)
Diffstat (limited to 'app/services')
-rw-r--r--app/services/fetch_link_card_service.rb8
-rw-r--r--app/services/process_feed_service.rb4
2 files changed, 6 insertions, 6 deletions
diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb
index dec4aabd6..ec9b5226e 100644
--- a/app/services/fetch_link_card_service.rb
+++ b/app/services/fetch_link_card_service.rb
@@ -84,10 +84,10 @@ class FetchLinkCardService < BaseService
 
     page = Nokogiri::HTML(response.to_s)
 
-    card.type        = :link
-    card.title       = meta_property(page, 'og:title') || page.at_xpath('//title')&.content
-    card.description = meta_property(page, 'og:description') || meta_property(page, 'description')
-    card.image       = URI.parse(Addressable::URI.parse(meta_property(page, 'og:image')).normalize.to_s) if meta_property(page, 'og:image')
+    card.type             = :link
+    card.title            = meta_property(page, 'og:title') || page.at_xpath('//title')&.content
+    card.description      = meta_property(page, 'og:description') || meta_property(page, 'description')
+    card.image_remote_url = meta_property(page, 'og:image') if meta_property(page, 'og:image')
 
     return if card.title.blank?
 
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index 04d6a100f..28ace7ae9 100644
--- a/app/services/process_feed_service.rb
+++ b/app/services/process_feed_service.rb
@@ -239,8 +239,8 @@ class ProcessFeedService < BaseService
 
         begin
           media.file_remote_url = link['href']
-          media.save
-        rescue OpenURI::HTTPError, OpenSSL::SSL::SSLError, Paperclip::Errors::NotIdentifiedByImageMagickError
+          media.save!
+        rescue ActiveRecord::RecordInvalid
           next
         end
       end