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.

28 lines
711 B

  1. class Api::SubscriptionsController < ApiController
  2. before_action :set_account
  3. def show
  4. if @account.subscription(api_subscription_url(@account.id)).valid?(params['hub.topic'], params['hub.verify_token'])
  5. render text: params['hub.challenge'], status: 200
  6. else
  7. render nothing: true, status: 404
  8. end
  9. end
  10. def update
  11. body = request.body.read
  12. if @account.subscription(api_subscription_url(@account.id)).verify(body, env['HTTP_X_HUB_SIGNATURE'])
  13. ProcessFeedService.new.(body, @account)
  14. render nothing: true, status: 201
  15. else
  16. render nothing: true, status: 202
  17. end
  18. end
  19. private
  20. def set_account
  21. @account = Account.find(params[:id])
  22. end
  23. end