(input: string)
| 40 | } |
| 41 | |
| 42 | export async function adminReprocessVideo(input: string) { |
| 43 | await requireAdmin(); |
| 44 | const videoId = parseVideoId(input); |
| 45 | |
| 46 | const [video] = await db() |
| 47 | .select({ |
| 48 | id: videos.id, |
| 49 | ownerId: videos.ownerId, |
| 50 | name: videos.name, |
| 51 | }) |
| 52 | .from(videos) |
| 53 | .where(eq(videos.id, videoId)); |
| 54 | |
| 55 | if (!video) { |
| 56 | throw new Error("Video not found"); |
| 57 | } |
| 58 | |
| 59 | const resultKey = `${video.ownerId}/${video.id}/result.mp4`; |
| 60 | await db() |
| 61 | .insert(videoUploads) |
| 62 | .values({ |
| 63 | videoId: video.id, |
| 64 | uploaded: 0, |
| 65 | total: 0, |
| 66 | mode: "singlepart", |
| 67 | phase: "processing", |
| 68 | processingProgress: 0, |
| 69 | processingMessage: "Queued admin reprocess...", |
| 70 | processingError: null, |
| 71 | rawFileKey: resultKey, |
| 72 | updatedAt: new Date(), |
| 73 | }) |
| 74 | .onDuplicateKeyUpdate({ |
| 75 | set: { |
| 76 | uploaded: 0, |
| 77 | total: 0, |
| 78 | mode: "singlepart", |
| 79 | phase: "processing", |
| 80 | processingProgress: 0, |
| 81 | processingMessage: "Queued admin reprocess...", |
| 82 | processingError: null, |
| 83 | rawFileKey: resultKey, |
| 84 | updatedAt: new Date(), |
| 85 | }, |
| 86 | }); |
| 87 | |
| 88 | await start(adminReprocessVideoWorkflow, [{ videoId }]); |
| 89 | |
| 90 | return { |
| 91 | videoId, |
| 92 | name: video.name, |
| 93 | shareUrl: `${serverEnv().WEB_URL}/s/${videoId}`, |
| 94 | }; |
| 95 | } |
no test coverage detected