mirror of
https://github.com/lunaisnotaboy/mastodon.git
synced 2024-11-14 02:42:54 +00:00
0717d9b3e6
- Rename Mastodon::TimestampIds into Mastodon::Snowflake for clarity - Skip for statuses coming from inbox, aka delivered in real-time - Skip for statuses that claim to be from the future
32 lines
880 B
Ruby
32 lines
880 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ProcessFeedService < BaseService
|
|
def call(body, account, options = {})
|
|
@options = options
|
|
|
|
xml = Nokogiri::XML(body)
|
|
xml.encoding = 'utf-8'
|
|
|
|
update_author(body, account)
|
|
process_entries(xml, account)
|
|
end
|
|
|
|
private
|
|
|
|
def update_author(body, account)
|
|
RemoteProfileUpdateWorker.perform_async(account.id, body.force_encoding('UTF-8'), true)
|
|
end
|
|
|
|
def process_entries(xml, account)
|
|
xml.xpath('//xmlns:entry', xmlns: OStatus::TagManager::XMLNS).reverse_each.map { |entry| process_entry(entry, account) }.compact
|
|
end
|
|
|
|
def process_entry(xml, account)
|
|
activity = OStatus::Activity::General.new(xml, account, @options)
|
|
activity.specialize&.perform if activity.status?
|
|
rescue ActiveRecord::RecordInvalid => e
|
|
Rails.logger.debug "Nothing was saved for #{activity.id} because: #{e}"
|
|
nil
|
|
end
|
|
end
|