1
0
Fork 0
forked from fedi/mastodon
mastodon/app/services/process_feed_service.rb

24 lines
684 B
Ruby
Raw Normal View History

2016-02-22 15:00:20 +00:00
class ProcessFeedService
2016-02-20 21:53:20 +00: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)
next if !status.nil?
2016-02-20 21:53:20 +00: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!
# todo: not everything is a status. there are follows, favourites
# todo: RTs
2016-02-20 21:53:20 +00:00
end
end
end