mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-23 04:55:08 +01:00
24 lines
684 B
Ruby
24 lines
684 B
Ruby
class ProcessFeedService
|
|
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?
|
|
|
|
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
|
|
end
|
|
end
|
|
end
|