Initial commit
This commit is contained in:
commit
9c4856bdb1
73 changed files with 1393 additions and 0 deletions
20
app/services/process_feed_update_service.rb
Normal file
20
app/services/process_feed_update_service.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
class ProcessFeedUpdateService
|
||||
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 unless 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!
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue