闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
741 B

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