mirror of https://github.com/buster-so/buster.git
access token check
This commit is contained in:
parent
6772641701
commit
5412fa5fa3
|
@ -516,20 +516,23 @@ export const analystAgentTask: ReturnType<
|
|||
totalWorkflowTimeMs: totalWorkflowTime,
|
||||
});
|
||||
|
||||
const supabaseUser = await getSupabaseUser(payload.access_token);
|
||||
if (supabaseUser) {
|
||||
await tasks.trigger(
|
||||
screenshots_task_keys.take_dashboard_screenshot,
|
||||
{
|
||||
dashboardId: payload.message_id,
|
||||
isOnSaveEvent: false,
|
||||
organizationId: messageContext.organizationId,
|
||||
supabaseCookieKey: getSupabaseCookieKey(),
|
||||
accessToken: payload.access_token,
|
||||
supabaseUser,
|
||||
} satisfies TakeDashboardScreenshotTrigger,
|
||||
{ concurrencyKey: `take-dashboard-screenshot-${payload.message_id}` }
|
||||
);
|
||||
//unfortuatenly slack messages don't have an access token...
|
||||
if (payload.access_token) {
|
||||
const supabaseUser = await getSupabaseUser(payload.access_token);
|
||||
if (supabaseUser) {
|
||||
await tasks.trigger(
|
||||
screenshots_task_keys.take_dashboard_screenshot,
|
||||
{
|
||||
dashboardId: payload.message_id,
|
||||
isOnSaveEvent: false,
|
||||
organizationId: messageContext.organizationId,
|
||||
supabaseCookieKey: getSupabaseCookieKey(),
|
||||
accessToken: payload.access_token,
|
||||
supabaseUser,
|
||||
} satisfies TakeDashboardScreenshotTrigger,
|
||||
{ concurrencyKey: `take-dashboard-screenshot-${payload.message_id}` }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Log final performance metrics
|
||||
|
|
|
@ -6,7 +6,7 @@ export const UUIDSchema = z.string().uuid('Must be a valid UUID');
|
|||
// Simple input schema - just message_id
|
||||
export const AnalystAgentTaskInputSchema = z.object({
|
||||
message_id: UUIDSchema,
|
||||
access_token: z.string(),
|
||||
access_token: z.string().nullable(),
|
||||
});
|
||||
|
||||
// Task execution result (for Trigger.dev monitoring)
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
} from '@buster/slack';
|
||||
import { type TaskOutput, logger, runs, schemaTask, wait } from '@trigger.dev/sdk';
|
||||
import { z } from 'zod';
|
||||
import type { AnalystAgentTaskInput } from '../analyst-agent-task';
|
||||
import { analystAgentTask } from '../analyst-agent-task/analyst-agent-task';
|
||||
import {
|
||||
createMessage,
|
||||
|
@ -338,7 +339,8 @@ export const slackAgentTask: ReturnType<
|
|||
const analystHandle = await analystAgentTask.trigger(
|
||||
{
|
||||
message_id: message.id,
|
||||
},
|
||||
access_token: null,
|
||||
} satisfies AnalystAgentTaskInput,
|
||||
{
|
||||
concurrencyKey: payload.chatId, // Ensure sequential processing per chat
|
||||
}
|
||||
|
|
|
@ -38,3 +38,10 @@ export const getSupabaseUser = async (jwtToken: string): Promise<User | null> =>
|
|||
const supabaseUser = await supabase.auth.getUser(jwtToken);
|
||||
return supabaseUser.data.user;
|
||||
};
|
||||
|
||||
export const getSupabaseAccessToken = async (userId: string) => {
|
||||
const supabase = getSupabaseClient();
|
||||
const supabaseUser = await supabase.auth.admin.getUserById(userId);
|
||||
|
||||
//
|
||||
};
|
||||
|
|
|
@ -33,6 +33,8 @@ export default defineConfig({
|
|||
'@duckdb/node-bindings-darwin-x64',
|
||||
'@duckdb/node-bindings-darwin-arm64',
|
||||
'@duckdb/node-bindings-win32-x64',
|
||||
'playwright-core',
|
||||
'chromium-bidi',
|
||||
],
|
||||
extensions: [
|
||||
esbuildPlugin({
|
||||
|
|
Loading…
Reference in New Issue