Fix the url builder for slack messages to have correct route

This commit is contained in:
Wells Bunker 2025-09-23 14:29:57 -06:00
parent 9eae2f6507
commit 2b6cdbe476
No known key found for this signature in database
GPG Key ID: DB16D6F2679B78FC
5 changed files with 5800 additions and 3 deletions

View File

@ -1,6 +1,7 @@
import { db, eq } from '@buster/database/connection';
import { checkForDuplicateMessages, updateMessage } from '@buster/database/queries';
import { chats, messages } from '@buster/database/schema';
import type { AssetType } from '@buster/server-shared';
import {
SlackMessagingService,
addReaction,
@ -653,7 +654,7 @@ export const slackAgentTask: ReturnType<
let responseText = "I've finished working on your request!";
let chatFileInfo: {
mostRecentFileId: string | null;
mostRecentFileType: string | null;
mostRecentFileType: AssetType | null;
mostRecentVersionNumber: number | null;
} | null = null;
@ -750,7 +751,16 @@ export const slackAgentTask: ReturnType<
chatFileInfo?.mostRecentFileType &&
chatFileInfo?.mostRecentVersionNumber !== null
) {
buttonUrl = `${busterUrl}/app/chats/${payload.chatId}/${chatFileInfo.mostRecentFileType}s/${chatFileInfo.mostRecentFileId}?${chatFileInfo.mostRecentFileType}_version_number=${chatFileInfo.mostRecentVersionNumber}`;
if (chatFileInfo.mostRecentFileType === 'dashboard_file') {
buttonUrl = `${busterUrl}/app/dashboards/${chatFileInfo.mostRecentFileId}?dashboard_version_number=${chatFileInfo.mostRecentVersionNumber}`;
} else if (chatFileInfo.mostRecentFileType === 'metric_file') {
buttonUrl = `${busterUrl}/app/metrics/${chatFileInfo.mostRecentFileId}?metric_version_number=${chatFileInfo.mostRecentVersionNumber}`;
} else if (chatFileInfo.mostRecentFileType === 'report_file') {
buttonUrl = `${busterUrl}/app/reports/${chatFileInfo.mostRecentFileId}?report_version_number=${chatFileInfo.mostRecentVersionNumber}`;
} else {
const _exhaustiveCheck: 'chat' | 'collection' = chatFileInfo.mostRecentFileType;
buttonUrl = `${busterUrl}/app/chats/${payload.chatId}`;
}
}
// Convert markdown to Slack format

View File

@ -0,0 +1,5 @@
-- Update existing values in chats table to match asset_type_enum values
UPDATE public"chats" SET "most_recent_file_type" = 'metric_file' WHERE "most_recent_file_type" = 'metric';--> statement-breakpoint
UPDATE public."chats" SET "most_recent_file_type" = 'dashboard_file' WHERE "most_recent_file_type" = 'dashboard';--> statement-breakpoint
UPDATE public."chats" SET "most_recent_file_type" = 'report_file' WHERE "most_recent_file_type" = 'report';--> statement-breakpoint
ALTER TABLE "chats" ALTER COLUMN "most_recent_file_type" SET DATA TYPE "public"."asset_type_enum" USING "most_recent_file_type"::"public"."asset_type_enum";--> statement-breakpoint

File diff suppressed because it is too large Load Diff

View File

@ -764,6 +764,13 @@
"when": 1758572594466,
"tag": "0109_icy_supernaut",
"breakpoints": true
},
{
"idx": 110,
"version": "7",
"when": 1758658933810,
"tag": "0110_third_ozymandias",
"breakpoints": true
}
]
}

View File

@ -848,7 +848,7 @@ export const chats = pgTable(
mode: 'string',
}),
mostRecentFileId: uuid('most_recent_file_id'),
mostRecentFileType: varchar('most_recent_file_type', { length: 255 }),
mostRecentFileType: assetTypeEnum('most_recent_file_type'),
mostRecentVersionNumber: integer('most_recent_version_number'),
slackChatAuthorization: slackChatAuthorizationEnum('slack_chat_authorization'),
slackThreadTs: text('slack_thread_ts'),