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.

26 lines
471 B

  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