From 785b9888dd4cfc4a61dad902f4dd2c2a97f23653 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 11 Jan 2023 09:07:15 -0500 Subject: [PATCH] Respond to slack url verification challenge with JSON instead of raw body --- server/routes/api/hooks.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/routes/api/hooks.ts b/server/routes/api/hooks.ts index 8c1beb100..30d7e84e7 100644 --- a/server/routes/api/hooks.ts +++ b/server/routes/api/hooks.ts @@ -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");