2016-02-23 02:00:20 +11:00
|
|
|
class ProcessFeedService
|
2016-02-21 08:53:20 +11:00
|
|
|
def call(body, account)
|
|
|
|
xml = Nokogiri::XML(body)
|
|
|
|
|
|
|
|
xml.xpath('/xmlns:feed/xmlns:entry').each do |entry|
|
|
|
|
uri = entry.at_xpath('./xmlns:id').content
|
|
|
|
status = Status.find_by(uri: uri)
|
|
|
|
|
2016-02-23 23:08:01 +11:00
|
|
|
next if !status.nil?
|
2016-02-21 08:53:20 +11:00
|
|
|
|
|
|
|
status = Status.new
|
|
|
|
status.account = account
|
|
|
|
status.uri = uri
|
|
|
|
status.text = entry.at_xpath('./xmlns:content').content
|
|
|
|
status.created_at = entry.at_xpath('./xmlns:published').content
|
|
|
|
status.updated_at = entry.at_xpath('./xmlns:updated').content
|
|
|
|
status.save!
|
2016-02-23 23:08:01 +11:00
|
|
|
|
|
|
|
# todo: not everything is a status. there are follows, favourites
|
|
|
|
# todo: RTs
|
2016-02-24 10:57:47 +11:00
|
|
|
# account.statuses.create!(reblog: status, uri: activity_uri(xml), url: activity_url(xml), text: content(xml))
|
2016-02-21 08:53:20 +11:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|