From 4a670780f0fda6891f1332e7a00c4b8f925634ed Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 22 Sep 2016 20:42:20 +0200 Subject: [PATCH] Fix #51 - prevent duplicate attachments for remote statuses --- app/services/process_feed_service.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb index 49834f5c16..9752233009 100644 --- a/app/services/process_feed_service.rb +++ b/app/services/process_feed_service.rb @@ -80,6 +80,10 @@ class ProcessFeedService < BaseService entry.xpath('./xmlns:link[@rel="enclosure"]').each do |enclosure_link| next if enclosure_link.attribute('href').nil? + media = MediaAttachment.where(status: status, remote_url: enclosure_link.attribute('href').value).first + + next unless media.nil? + media = MediaAttachment.new(account: status.account, status: status, remote_url: enclosure_link.attribute('href').value) media.file_remote_url = enclosure_link.attribute('href').value media.save