- fix lower case slack

- return error response on slack bot verification
- auth scope fix
This commit is contained in:
dal 2025-08-18 13:28:32 -06:00
parent c1f9ca3622
commit 35193e53ce
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
3 changed files with 19 additions and 11 deletions

View File

@ -2,7 +2,6 @@ export const SLACK_OAUTH_SCOPES = [
'app_mentions:read',
'channels:history',
'channels:join',
'channels:manage',
'channels:read',
'chat:write',
'chat:write.public',

View File

@ -141,12 +141,21 @@ export async function handleSlackEventsEndpoint(c: Context) {
const payload = c.get('slackPayload');
if (!payload) {
// This shouldn't happen if middleware works correctly
return c.json({ success: false });
return c.json({ error: 'Unauthorized' }, 401);
}
// Process the event
const response = await eventsHandler(payload);
return c.json(response);
try {
// Process the event
const response = await eventsHandler(payload);
return c.json(response);
} catch (error) {
// Handle authentication errors
if (error instanceof Error && error.message.includes('Unauthorized')) {
return c.json({ error: 'Unauthorized' }, 401);
}
// Re-throw other errors
throw error;
}
}
/**
@ -179,8 +188,8 @@ export async function eventsHandler(payload: SlackWebhookPayload): Promise<Slack
teamId: payload.team_id,
reason: authResult.type === 'unauthorized' ? authResult.reason : 'Unknown',
});
// Return success to prevent Slack retries
return { success: true };
// Throw unauthorized error
throw new Error('Unauthorized: Slack user authentication failed');
}
const organizationId = authResult.type === 'unauthorized' ? '' : authResult.organization.id;

View File

@ -39,7 +39,7 @@ export const SlackIntegrations = React.memo(() => {
}, [isConnected]);
if (slackIntegrationError) {
return <StatusCard message="Error fetching slack integration." variant={'danger'} />;
return <StatusCard message="Error fetching Slack integration." variant={'danger'} />;
}
if (!isFetchedSlackIntegration) {
@ -67,7 +67,7 @@ const ConnectSlackCard = React.memo(() => {
<div className="flex flex-col space-y-0.5">
<Text>Slack account</Text>
<Text variant="secondary" size={'xs'}>
Link your slack account to use Buster from Slack
Link your Slack account to use Buster from Slack
</Text>
</div>
</div>
@ -166,7 +166,7 @@ const ConnectedSlackChannels = React.memo(() => {
<div className="flex flex-col space-y-0.5">
<Text>Alerts channel</Text>
<Text variant="secondary" size={'xs'}>
Select which slack channel Buster should send alerts to
Select which Slack channel Buster should send alerts to
</Text>
</div>
<div className="flex min-w-0 flex-1 items-center justify-end space-x-2">
@ -262,7 +262,7 @@ const SlackSharingPermissions = React.memo(() => {
<div className="flex flex-col space-y-0.5">
<Text>Auto-share chats with other users</Text>
<Text variant="secondary" size={'xs'}>
Specify how chats are auto-shared when created from slack channels
Specify how chats are auto-shared when created from Slack channels
</Text>
</div>
<Dropdown