0
0
Fork 0

PostStatusService can attach media to status, ProcessFeedService likewise

This commit is contained in:
Eugen Rochko 2016-09-05 18:39:53 +02:00
parent ae1fac0062
commit eec0dc46a6
12 changed files with 32 additions and 85 deletions

View file

@ -38,6 +38,7 @@ class ProcessFeedService < BaseService
# If we added a status, go through accounts it mentions and create respective relations
unless status.new_record?
record_remote_mentions(status, entry.xpath('./xmlns:link[@rel="mentioned"]'))
process_attachments(entry, status)
DistributionWorker.perform_async(status.id)
end
end
@ -68,6 +69,16 @@ class ProcessFeedService < BaseService
end
end
def process_attachments(entry, status)
entry.xpath('./xmlns:link[@rel="enclosure"]').each do |enclosure_link|
next if enclosure_link.attribute('href').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
end
end
def add_post!(_entry, status)
status.save!
end