update_remote_profile_service.rb 613 B

12345678910111213141516171819
  1. class UpdateRemoteProfileService < BaseService
  2. def call(author_xml, account)
  3. if author_xml.at_xpath('./poco:displayName').nil?
  4. account.display_name = account.username
  5. else
  6. account.display_name = author_xml.at_xpath('./poco:displayName').content
  7. end
  8. unless author_xml.at_xpath('./poco:note').nil?
  9. account.note = author_xml.at_xpath('./poco:note').content
  10. end
  11. unless author_xml.at_xpath('./xmlns:link[@rel="avatar"]').nil?
  12. account.avatar_remote_url = author_xml.at_xpath('./xmlns:link[@rel="avatar"]').attribute('href').value
  13. end
  14. account.save!
  15. end
  16. end