mirror of https://github.com/buster-so/buster.git
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:
commit
fc2a50c31e
|
@ -0,0 +1,4 @@
|
|||
export async function eventsHandler(_body: unknown): Promise<{ success: boolean }> {
|
||||
// Simply accept any JSON payload and return success
|
||||
return { success: true };
|
||||
}
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue