Open a bot's own files from a workspace conversation
A workspace run saves to the bot's own folder unless it picks the workspace's, but a file chip in a workspace conversation only looked in the workspace's folder, so those refs rendered as dead text. The chip now sends both ids and the single-file lookup also searches the bot's own folder for a user who reaches that bot. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -27,10 +27,13 @@ function fetchFile({
|
||||
|
||||
if (cached) return cached;
|
||||
|
||||
const query = new URLSearchParams({ file_id: String(file_id) });
|
||||
/**
|
||||
* Both ids in a workspace: a bot working there saves to its own folder
|
||||
* unless it picks the workspace's, and the chip has to find either.
|
||||
*/
|
||||
const query = new URLSearchParams({ file_id: String(file_id), bot_id: String(bot_id) });
|
||||
|
||||
if (workspace_id) query.set("workspace_id", String(workspace_id));
|
||||
else query.set("bot_id", String(bot_id));
|
||||
|
||||
const pending = fetchApi<{}, APIResponseObject<BotFileScopesPayload>>(
|
||||
`/api/admin/bots/files?${query.toString()}`,
|
||||
|
||||
@@ -56,7 +56,17 @@ export const handler: BunextAPIRouteHandler<APIResponseObject<BotFileScopesPaylo
|
||||
const scopes = [scope];
|
||||
|
||||
if (file_id) {
|
||||
const file = await grabBotFile({ scopes, file_id });
|
||||
/**
|
||||
* A workspace run saves to the bot's own folder by default
|
||||
* (`grabStorageScopes`, own first), so a chip in a workspace
|
||||
* conversation looks there too, for a user who reaches that bot
|
||||
* (the same reach `grabBotFileMedia` checks before the bytes).
|
||||
*/
|
||||
const file_scopes =
|
||||
scope.scope == "workspace" && bot_id && (await grabUserBot({ bot_id, user_id: user.id }))
|
||||
? [...scopes, { scope: "bot" as const, owner_id: bot_id }]
|
||||
: scopes;
|
||||
const file = await grabBotFile({ scopes: file_scopes, file_id });
|
||||
|
||||
if (!file?.id) return { success: false, msg: `Not found.` };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user