MCPcopy
hub / github.com/CapSoftware/Cap / validateEditRequest

Function validateEditRequest

apps/web/workflows/edit-video.ts:120–155  ·  view source on GitHub ↗
(
	videoId: string,
	sourceKey: string,
)

Source from the content-addressed store, hash-verified

118}
119
120async 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
157async function startMediaServerEditJob(
158 mediaServerUrl: string,

Callers 1

editVideoWorkflowFunction · 0.85

Calls 2

serverEnvFunction · 0.90
dbFunction · 0.90

Tested by

no test coverage detected