闭社主体 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.

25 lines
841 B

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