Files
danbooru/app/controllers/webhooks_controller.rb
evazion 2c8c7ff80a discord: add initial slash command integration.
Add initial support for the `/count <tags>` and `/posts <tags>` slash commands.

Slash commands are basically like webhooks; we register a command, and
when anybody types that command in Discord, Discord sends us a HTTP
request that we respond to.

* https://discord.com/developers/docs/interactions/slash-commands
* https://support.discord.com/hc/en-us/articles/1500000368501-Slash-Commands-FAQ
2021-03-11 03:04:10 -06:00

19 lines
484 B
Ruby

class WebhooksController < ApplicationController
skip_forgery_protection only: :receive
rescue_with Stripe::SignatureVerificationError, status: 400
rescue_with DiscordSlashCommand::WebhookVerificationError, status: 401
def receive
case params[:source]
when "stripe"
UserUpgrade.receive_webhook(request)
head 200
when "discord"
json = DiscordSlashCommand.receive_webhook(request)
render json: json
else
head 400
end
end
end