Respond to slack url verification challenge with JSON instead of raw body

This commit is contained in:
Tom Moor
2023-01-11 09:07:15 -05:00
parent d5158f0a34
commit 785b9888dd

View File

@@ -46,8 +46,14 @@ function verifySlackToken(token: string) {
// triggered by a user posting a getoutline.com link in Slack
router.post("hooks.unfurl", async (ctx: APIContext) => {
const { challenge, token, event } = ctx.request.body;
// See URL verification handshake documentation on this page:
// https://api.slack.com/apis/connections/events-api
if (challenge) {
return (ctx.body = ctx.request.body.challenge);
ctx.body = {
challenge,
};
return;
}
assertPresent(token, "token is required");