about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-22 20:42:20 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-22 20:42:20 +0200
commit4a670780f0fda6891f1332e7a00c4b8f925634ed (patch)
treef509af9f2b2cc21c5ab4b23be94819969feaa460
parentd09f3768b7c7a547a1aaf38e3d5d2de699762d30 (diff)
Fix #51 - prevent duplicate attachments for remote statuses
-rw-r--r--app/services/process_feed_service.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index 49834f5c1..975223300 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