Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: use cheap mobile download guard

Richie McIlroy40339496e289
diff --git a/apps/web/app/api/mobile/[...route]/route.ts b/apps/web/app/api/mobile/[...route]/route.ts
index 20a7829c8..4e07ea46e 100644
--- a/apps/web/app/api/mobile/[...route]/route.ts
+++ b/apps/web/app/api/mobile/[...route]/route.ts
@@ -1302,7 +1302,18 @@ const ApiLive = HttpApiBuilder.api(Mobile.MobileApiContract).pipe(
.handle("getDownload", ({ path }) =>
withMappedErrors(
Effect.gen(function* () {
- yield* getCapById(path.id);
+ const user = yield* CurrentUser;
+ const [video] = yield* videos.getByIdForViewing(path.id).pipe(
+ Effect.flatten,
+ Effect.catchTag(
+ "NoSuchElementException",
+ () => new Video.NotFoundError(),
+ ),
+ );
+ if (video.ownerId !== user.id) {
+ return yield* Effect.fail(new HttpApiError.NotFound());
+ }
+
return yield* videos.getDownloadInfo(path.id).pipe(
Effect.flatMap(
Option.match({