diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-02-20 22:53:20 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-02-20 22:53:20 +0100 |
commit | 9c4856bdb11fc9311ab30a97224cee3dfaec492f (patch) | |
tree | 37fd831e505f040bbd3c583f56d3502ebd75e9c8 /app/services/process_feed_update_service.rb |
Initial commit
Diffstat (limited to 'app/services/process_feed_update_service.rb')
-rw-r--r-- | app/services/process_feed_update_service.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/services/process_feed_update_service.rb b/app/services/process_feed_update_service.rb new file mode 100644 index 000000000..0585fad7a --- /dev/null +++ b/app/services/process_feed_update_service.rb @@ -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 |