mirror of https://github.com/buster-so/buster.git
Fix CI failures: correct import paths and user organization access
- Import database queries from main @buster/database package - Use getUserOrganizationId() instead of user.organizationId - Add proper error handling for users without organizations - Follow existing patterns from other API handlers Co-Authored-By: nate@buster.so <nate@buster.so>
This commit is contained in:
parent
5b40205275
commit
783b95b190
|
@ -1,5 +1,4 @@
|
||||||
import { getChatTitle } from '@buster/database/queries/chats';
|
import { getChatTitle, getCollectionTitle, getDashboardTitle, getMetricTitle, getUserOrganizationId } from '@buster/database';
|
||||||
import { getCollectionTitle, getDashboardTitle, getMetricTitle } from '@buster/database/queries/assets';
|
|
||||||
import { GetTitleRequestSchema, type GetTitleResponse } from '@buster/server-shared/title';
|
import { GetTitleRequestSchema, type GetTitleResponse } from '@buster/server-shared/title';
|
||||||
import { zValidator } from '@hono/zod-validator';
|
import { zValidator } from '@hono/zod-validator';
|
||||||
import { Hono } from 'hono';
|
import { Hono } from 'hono';
|
||||||
|
@ -14,20 +13,25 @@ const app = new Hono()
|
||||||
const { assetId, assetType } = c.req.valid('query');
|
const { assetId, assetType } = c.req.valid('query');
|
||||||
const user = c.get('busterUser');
|
const user = c.get('busterUser');
|
||||||
|
|
||||||
|
const userOrg = await getUserOrganizationId(user.id);
|
||||||
|
if (!userOrg) {
|
||||||
|
throw new HTTPException(403, { message: 'User is not associated with an organization' });
|
||||||
|
}
|
||||||
|
|
||||||
let title: string | null = null;
|
let title: string | null = null;
|
||||||
|
|
||||||
switch (assetType) {
|
switch (assetType) {
|
||||||
case 'chat':
|
case 'chat':
|
||||||
title = await getChatTitle({ assetId, organizationId: user.organizationId });
|
title = await getChatTitle({ assetId, organizationId: userOrg.organizationId });
|
||||||
break;
|
break;
|
||||||
case 'metric':
|
case 'metric':
|
||||||
title = await getMetricTitle({ assetId, organizationId: user.organizationId });
|
title = await getMetricTitle({ assetId, organizationId: userOrg.organizationId });
|
||||||
break;
|
break;
|
||||||
case 'collection':
|
case 'collection':
|
||||||
title = await getCollectionTitle({ assetId, organizationId: user.organizationId });
|
title = await getCollectionTitle({ assetId, organizationId: userOrg.organizationId });
|
||||||
break;
|
break;
|
||||||
case 'dashboard':
|
case 'dashboard':
|
||||||
title = await getDashboardTitle({ assetId, organizationId: user.organizationId });
|
title = await getDashboardTitle({ assetId, organizationId: userOrg.organizationId });
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
const _exhaustive: never = assetType;
|
const _exhaustive: never = assetType;
|
||||||
|
|
Loading…
Reference in New Issue