1
0

verify_salmon_service.rb 471 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. class VerifySalmonService < BaseService
  3. include AuthorExtractor
  4. def call(payload)
  5. body = salmon.unpack(payload)
  6. xml = Nokogiri::XML(body)
  7. xml.encoding = 'utf-8'
  8. account = author_from_xml(xml.at_xpath('/xmlns:entry', xmlns: TagManager::XMLNS))
  9. if account.nil?
  10. false
  11. else
  12. salmon.verify(payload, account.keypair)
  13. end
  14. end
  15. private
  16. def salmon
  17. @salmon ||= OStatus2::Salmon.new
  18. end
  19. end