( videoId: string, sourceKey: string, )
| 118 | } |
| 119 | |
| 120 | async function validateEditRequest( |
| 121 | videoId: string, |
| 122 | sourceKey: string, |
| 123 | ): Promise<void> { |
| 124 | "use step"; |
| 125 | |
| 126 | if (!serverEnv().MEDIA_SERVER_URL) { |
| 127 | throw new FatalError("MEDIA_SERVER_URL is not configured"); |
| 128 | } |
| 129 | |
| 130 | const [video] = await db() |
| 131 | .select() |
| 132 | .from(videos) |
| 133 | .where(eq(videos.id, videoId as Video.VideoId)); |
| 134 | |
| 135 | if (!video) { |
| 136 | throw new FatalError("Video does not exist"); |
| 137 | } |
| 138 | |
| 139 | const [upload] = await db() |
| 140 | .select() |
| 141 | .from(videoUploads) |
| 142 | .where(eq(videoUploads.videoId, videoId as Video.VideoId)); |
| 143 | |
| 144 | if (!upload) { |
| 145 | throw new FatalError("Edit render does not exist"); |
| 146 | } |
| 147 | |
| 148 | if (upload.rawFileKey !== sourceKey) { |
| 149 | throw new FatalError("Edit source key does not match"); |
| 150 | } |
| 151 | |
| 152 | if (upload.phase !== "processing") { |
| 153 | throw new FatalError("Video is not ready for edit rendering"); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | async function startMediaServerEditJob( |
| 158 | mediaServerUrl: string, |
no test coverage detected