about summary refs log tree commit diff
path: root/app/services/update_remote_profile_service.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-02-28 14:26:26 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-02-28 14:26:26 +0100
commitad5ae3f60e5e0745912bfbc0926f6cf8bc6e9eb4 (patch)
tree628535474e7f446869cab55f8cdcde56798229be /app/services/update_remote_profile_service.rb
parent2825991e09272d6e7227da9d9b8dc387614a83df (diff)
Update profile information and download avatar of remote accounts
Diffstat (limited to 'app/services/update_remote_profile_service.rb')
-rw-r--r--app/services/update_remote_profile_service.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/services/update_remote_profile_service.rb b/app/services/update_remote_profile_service.rb
new file mode 100644
index 000000000..5f1d3caeb
--- /dev/null
+++ b/app/services/update_remote_profile_service.rb
@@ -0,0 +1,19 @@
+class UpdateRemoteProfileService < BaseService
+  def call(author_xml, account)
+    if author_xml.at_xpath('./poco:displayName').nil?
+      account.display_name = account.username
+    else
+      account.display_name = author_xml.at_xpath('./poco:displayName').content
+    end
+
+    unless author_xml.at_xpath('./poco:note').nil?
+      account.note = author_xml.at_xpath('./poco:note').content
+    end
+
+    unless author_xml.at_xpath('./xmlns:link[@rel="avatar"]').nil?
+      account.avatar_remote_url = author_xml.at_xpath('./xmlns:link[@rel="avatar"]').attribute('href').value
+    end
+
+    account.save!
+  end
+end