({
videoId,
rawFileKey,
bucketId,
}: {
videoId: Video.VideoId;
rawFileKey: string;
bucketId: string | null;
})
| 31 | } |
| 32 | |
| 33 | export async function triggerVideoProcessing({ |
| 34 | videoId, |
| 35 | rawFileKey, |
| 36 | bucketId, |
| 37 | }: { |
| 38 | videoId: Video.VideoId; |
| 39 | rawFileKey: string; |
| 40 | bucketId: string | null; |
| 41 | }): Promise<{ success: boolean }> { |
| 42 | const user = await getCurrentUser(); |
| 43 | if (!user) throw new Error("Unauthorized"); |
| 44 | |
| 45 | const [video] = await db() |
| 46 | .select() |
| 47 | .from(videos) |
| 48 | .where(eq(videos.id, videoId)); |
| 49 | |
| 50 | if (!video) throw new Error("Video not found"); |
| 51 | if (video.ownerId !== user.id) throw new Error("Unauthorized"); |
| 52 | |
| 53 | await verifyRawFileUploaded(video, rawFileKey); |
| 54 | |
| 55 | await startVideoProcessingWorkflow({ |
| 56 | videoId, |
| 57 | userId: user.id, |
| 58 | rawFileKey, |
| 59 | bucketId, |
| 60 | processingMessage: "Starting video processing...", |
| 61 | startFailureMessage: "Video processing could not start.", |
| 62 | }); |
| 63 | |
| 64 | return { success: true }; |
| 65 | } |
no test coverage detected