Merge pull request #486 from buster-so/dallin/bus-1360-slack-button-still-has-alert

Add events endpoint for Slack webhooks without authentication
This commit is contained in:
dal 2025-07-11 14:48:49 -07:00 committed by GitHub
commit fc2a50c31e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,4 @@
export async function eventsHandler(_body: unknown): Promise<{ success: boolean }> {
// Simply accept any JSON payload and return success
return { success: true };
}

View File

@ -2,6 +2,7 @@ import { SlackError } from '@buster/server-shared/slack';
import { Hono } from 'hono';
import { HTTPException } from 'hono/http-exception';
import { requireAuth } from '../../../middleware/auth';
import { eventsHandler } from './events';
import { slackHandler } from './handler';
const app = new Hono()
@ -13,6 +14,12 @@ const app = new Hono()
.put('/integration', requireAuth, (c) => slackHandler.updateIntegration(c))
.get('/channels', requireAuth, (c) => slackHandler.getChannels(c))
.delete('/integration', requireAuth, (c) => slackHandler.removeIntegration(c))
// Events endpoint (no auth required for Slack webhooks)
.post('/events', async (c) => {
const body = await c.req.json();
const response = await eventsHandler(body);
return c.json(response);
})
// Error handling
.onError((e, c) => {
if (e instanceof SlackError) {