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.

33 lines
573 B

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