mirror of https://github.com/buster-so/buster.git
- fix lower case slack
- return error response on slack bot verification - auth scope fix
This commit is contained in:
parent
c1f9ca3622
commit
35193e53ce
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue