dvijaykrishnan's picture
Deployment fix for HF
ceb943f
Raw
History Blame Contribute Delete
888 Bytes
import { db } from '@/lib/db';
import { detectedObjects, youtubeVideos, youtubeChannels } from '@/lib/db/schema';
import { eq } from 'drizzle-orm';
export const DEMO_USER_ID = 'demo-user-showcase';
/**
* Checks if a detection belongs to the public showcase demo user.
* Used to allow anonymous moderation in showcase mode.
*/
export async function isDemoDetection(detectionId: string) {
const detection = await db
.select({
id: detectedObjects.id,
creatorId: youtubeChannels.creatorId,
})
.from(detectedObjects)
.innerJoin(youtubeVideos, eq(detectedObjects.videoId, youtubeVideos.id))
.innerJoin(youtubeChannels, eq(youtubeVideos.channelId, youtubeChannels.id))
.where(eq(detectedObjects.id, detectionId))
.limit(1)
.then(res => res[0]);
return detection?.creatorId === DEMO_USER_ID;
}