PostStatusService can attach media to status, ProcessFeedService likewise
This commit is contained in:
parent
ae1fac0062
commit
eec0dc46a6
12 changed files with 32 additions and 85 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue