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.

29 lines
692 B

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