logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

salmon_controller.rb (704B)


  1. # frozen_string_literal: true
  2. class Api::SalmonController < Api::BaseController
  3. include SignatureVerification
  4. before_action :set_account
  5. respond_to :txt
  6. def update
  7. if verify_payload?
  8. process_salmon
  9. head 202
  10. elsif payload.present?
  11. render plain: signature_verification_failure_reason, status: 401
  12. else
  13. head 400
  14. end
  15. end
  16. private
  17. def set_account
  18. @account = Account.find(params[:id])
  19. end
  20. def payload
  21. @_payload ||= request.body.read
  22. end
  23. def verify_payload?
  24. payload.present? && VerifySalmonService.new.call(payload)
  25. end
  26. def process_salmon
  27. SalmonWorker.perform_async(@account.id, payload.force_encoding('UTF-8'))
  28. end
  29. end