89b988cab5
* Wrap methods of ProcessFeedService::ProcessEntry in classes
This is a change same with 425acecfdb
, except
that it has the following changes:
* Revert irrelevant change in find_or_create_conversation
* Fix error handling for RemoteActivity
* Introduce Ostatus name space
30 lines
814 B
Ruby
30 lines
814 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ProcessFeedService < BaseService
|
|
def call(body, account)
|
|
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: TagManager::XMLNS).reverse_each.map { |entry| process_entry(entry, account) }.compact
|
|
end
|
|
|
|
def process_entry(xml, account)
|
|
activity = Ostatus::Activity::General.new(xml, account)
|
|
activity.specialize&.perform if activity.status?
|
|
rescue ActiveRecord::RecordInvalid => e
|
|
Rails.logger.debug "Nothing was saved for #{id} because: #{e}"
|
|
nil
|
|
end
|
|
end
|