You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
684 B

8 years ago
8 years ago
8 years ago
  1. class ProcessFeedService
  2. def call(body, account)
  3. xml = Nokogiri::XML(body)
  4. xml.xpath('/xmlns:feed/xmlns:entry').each do |entry|
  5. uri = entry.at_xpath('./xmlns:id').content
  6. status = Status.find_by(uri: uri)
  7. next if !status.nil?
  8. status = Status.new
  9. status.account = account
  10. status.uri = uri
  11. status.text = entry.at_xpath('./xmlns:content').content
  12. status.created_at = entry.at_xpath('./xmlns:published').content
  13. status.updated_at = entry.at_xpath('./xmlns:updated').content
  14. status.save!
  15. # todo: not everything is a status. there are follows, favourites
  16. # todo: RTs
  17. end
  18. end
  19. end