From 79ef8b3653a6ff7edbc1af0741dff36522262c07 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Thu, 18 May 2017 22:43:10 +0900 Subject: Fetch remote image using http.rb (#3114) --- app/services/fetch_link_card_service.rb | 8 ++++---- app/services/process_feed_service.rb | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'app/services') 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 -- cgit