Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
use properly auth checks for getVideoStatus
Brendan Allan50fe2116ecd7
diff --git a/apps/web/actions/videos/get-status.ts b/apps/web/actions/videos/get-status.tsindex 1c8b1764d..e3103167f 100644--- a/apps/web/actions/videos/get-status.ts+++ b/apps/web/actions/videos/get-status.ts@@ -5,6 +5,7 @@ import { getCurrentUser } from "@cap/database/auth/session";import { users, videos } from "@cap/database/schema";import type { VideoMetadata } from "@cap/database/types";import { eq } from "drizzle-orm";+import { userHasAccessToVideo } from "@/utils/auth";import { isAiGenerationEnabled } from "@/utils/flags";import { transcribeVideo } from "../../lib/transcribe";import { generateAiMetadata } from "./generate-ai-metadata";@@ -23,12 +24,8 @@ export interface VideoStatusResult {export async function getVideoStatus(videoId: string,-): Promise<VideoStatusResult> {- const user = await getCurrentUser();-- if (!user) {- throw new Error("Authentication required");- }+): Promise<VideoStatusResult | { success: false; access: string }> {+ const userPromise = getCurrentUser();if (!videoId) {throw new Error("Video ID not provided");@@ -229,6 +226,9 @@ export async function getVideoStatus(}}+ const access = await userHasAccessToVideo(userPromise, video);+ if (access !== "has-access") return { success: false, access };+return {transcriptionStatus:(video.transcriptionStatus as "PROCESSING" | "COMPLETE" | "ERROR") ||diff --git a/apps/web/app/s/[videoId]/Share.tsx b/apps/web/app/s/[videoId]/Share.tsxindex 6af3ddc5e..27942428a 100644--- a/apps/web/app/s/[videoId]/Share.tsx+++ b/apps/web/app/s/[videoId]/Share.tsx@@ -77,7 +77,10 @@ const useVideoStatus = (return useQuery({queryKey: ["videoStatus", videoId],queryFn: async (): Promise<VideoStatusResult> => {- return await getVideoStatus(videoId);+ const res = await getVideoStatus(videoId);+ if ("success" in res && res.success === false)+ throw new Error("Failed to fetch video status");+ return res as VideoStatusResult;},initialData: initialData? {