Skip to content

Commit

Permalink
hopefully enables webhook ingestion
Browse files Browse the repository at this point in the history
Signed-off-by: CyberFlame <[email protected]>
  • Loading branch information
CyberFlameGO authored Oct 27, 2024
1 parent 70e6804 commit 1c35eff
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,21 @@ router.get('/oauth-callback', async (c) => {
}
});

router.post('/webhooks', async (c) => {
const signature = c.req.header('x-signature-ed25519')!;
const timestamp = c.req.header('x-signature-timestamp')!;
const body = await c.req.text();
if (!(await verifyKey(body, signature as string, timestamp, c.env.DISCORD_PUBLIC_KEY)))
return new Response('Invalid request', { status: 401 });
const interaction = await c.req.json();

switch (interaction["type"]) {
case "PING": {
return Response(status=204)
}
}
}

router.all('*', () => new Response('Not Found.', { status: 404 }));

export default router;

0 comments on commit 1c35eff

Please sign in to comment.