File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { getCurrentUser } from "@cap/database/auth/session";
5
5
import { users , videos } from "@cap/database/schema" ;
6
6
import type { VideoMetadata } from "@cap/database/types" ;
7
7
import { eq } from "drizzle-orm" ;
8
+ import { userHasAccessToVideo } from "@/utils/auth" ;
8
9
import { isAiGenerationEnabled } from "@/utils/flags" ;
9
10
import { transcribeVideo } from "../../lib/transcribe" ;
10
11
import { generateAiMetadata } from "./generate-ai-metadata" ;
@@ -23,12 +24,8 @@ export interface VideoStatusResult {
23
24
24
25
export async function getVideoStatus (
25
26
videoId : string ,
26
- ) : Promise < VideoStatusResult > {
27
- const user = await getCurrentUser ( ) ;
28
-
29
- if ( ! user ) {
30
- throw new Error ( "Authentication required" ) ;
31
- }
27
+ ) : Promise < VideoStatusResult | { success : false ; access : string } > {
28
+ const userPromise = getCurrentUser ( ) ;
32
29
33
30
if ( ! videoId ) {
34
31
throw new Error ( "Video ID not provided" ) ;
@@ -229,6 +226,9 @@ export async function getVideoStatus(
229
226
}
230
227
}
231
228
229
+ const access = await userHasAccessToVideo ( userPromise , video ) ;
230
+ if ( access !== "has-access" ) return { success : false , access } ;
231
+
232
232
return {
233
233
transcriptionStatus :
234
234
( video . transcriptionStatus as "PROCESSING" | "COMPLETE" | "ERROR" ) ||
Original file line number Diff line number Diff line change @@ -77,7 +77,10 @@ const useVideoStatus = (
77
77
return useQuery ( {
78
78
queryKey : [ "videoStatus" , videoId ] ,
79
79
queryFn : async ( ) : Promise < VideoStatusResult > => {
80
- return await getVideoStatus ( videoId ) ;
80
+ const res = await getVideoStatus ( videoId ) ;
81
+ if ( "success" in res && res . success === false )
82
+ throw new Error ( "Failed to fetch video status" ) ;
83
+ return res as VideoStatusResult ;
81
84
} ,
82
85
initialData : initialData
83
86
? {
You can’t perform that action at this time.
0 commit comments