Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(web): queue transcription after media server processing

Richie McIlroyfd3f10f0a93b
diff --git a/apps/web/app/api/webhooks/media-server/progress/route.ts b/apps/web/app/api/webhooks/media-server/progress/route.ts
index 2248e07a2..2365a59b9 100644
--- a/apps/web/app/api/webhooks/media-server/progress/route.ts
+++ b/apps/web/app/api/webhooks/media-server/progress/route.ts
@@ -6,6 +6,10 @@ import type { Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { type NextRequest, NextResponse } from "next/server";
import { invalidateGoogleDriveStorageQuotaCache } from "@/lib/google-drive-storage-quota";
+import {
+ queueVideoTranscription,
+ shouldQueueTranscriptionAfterMediaComplete,
+} from "@/lib/queue-video-transcription";
import { isEditSourceKey } from "@/lib/video-edit-processing";
interface ProgressWebhookPayload {
@@ -153,6 +157,30 @@ export async function POST(request: NextRequest) {
await invalidateGoogleDriveStorageQuotaCache(
currentVideo?.storageIntegrationId,
);
+
+ if (
+ shouldQueueTranscriptionAfterMediaComplete(
+ currentVideo?.source.type,
+ Boolean(isEditUpload),
+ )
+ ) {
+ try {
+ const result = await queueVideoTranscription(
+ payload.videoId as Video.VideoId,
+ );
+ if (!result.success) {
+ console.warn(
+ "[media-server-webhook] Failed to queue transcription",
+ { videoId: payload.videoId, message: result.message },
+ );
+ }
+ } catch (error) {
+ console.warn("[media-server-webhook] Failed to queue transcription", {
+ videoId: payload.videoId,
+ error,
+ });
+ }
+ }
} else if (dbPhase === "error") {
const processingError =
payload.error || payload.message || "Unknown error";