( videoId: string, rawFileKey: string, )
| 67 | } |
| 68 | |
| 69 | async function validateProcessingRequest( |
| 70 | videoId: string, |
| 71 | rawFileKey: string, |
| 72 | ): Promise<void> { |
| 73 | "use step"; |
| 74 | |
| 75 | const mediaServerUrl = serverEnv().MEDIA_SERVER_URL; |
| 76 | if (!mediaServerUrl) { |
| 77 | throw new FatalError("MEDIA_SERVER_URL is not configured"); |
| 78 | } |
| 79 | |
| 80 | const [video] = await db() |
| 81 | .select() |
| 82 | .from(videos) |
| 83 | .where(eq(videos.id, videoId as Video.VideoId)); |
| 84 | |
| 85 | if (!video) { |
| 86 | throw new FatalError("Video does not exist"); |
| 87 | } |
| 88 | |
| 89 | const [upload] = await db() |
| 90 | .select() |
| 91 | .from(videoUploads) |
| 92 | .where(eq(videoUploads.videoId, videoId as Video.VideoId)); |
| 93 | |
| 94 | if (!upload) { |
| 95 | throw new FatalError("Upload does not exist"); |
| 96 | } |
| 97 | |
| 98 | if (upload.rawFileKey !== rawFileKey) { |
| 99 | throw new FatalError("Upload raw file key does not match"); |
| 100 | } |
| 101 | |
| 102 | if (upload.phase !== "processing") { |
| 103 | throw new FatalError("Upload is not ready for processing"); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | interface MediaServerProcessResult { |
| 108 | metadata: { |
no test coverage detected