Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: shareable links for manual uploads (#977)

Ameer Al Ashhab6e12f49f048e
diff --git a/apps/web/actions/video/upload.ts b/apps/web/actions/video/upload.ts
index b12658ff5..d6dc394a3 100644
--- a/apps/web/actions/video/upload.ts
+++ b/apps/web/actions/video/upload.ts
@@ -8,10 +8,11 @@ import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { nanoId } from "@cap/database/helpers";
import { s3Buckets, videos } from "@cap/database/schema";
-import { serverEnv } from "@cap/env";
+import { buildEnv, NODE_ENV, serverEnv } from "@cap/env";
import { userIsPro } from "@cap/utils";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
+import { dub } from "@/utils/dub";
import { createBucketProvider } from "@/utils/s3";
async function getVideoUploadPresignedUrl({
@@ -241,7 +242,21 @@ export async function createVideoAndGetUploadUrl({
audioCodec,
});
+ if (buildEnv.NEXT_PUBLIC_IS_CAP && NODE_ENV === "production") {
+ await dub()
+ .links.create({
+ url: `${serverEnv().WEB_URL}/s/${idToUse}`,
+ domain: "cap.link",
+ key: idToUse,
+ })
+ .catch((err) => {
+ console.error("Dub link create failed", err);
+ });
+ }
+
+ revalidatePath("/dashboard/caps");
revalidatePath("/dashboard/folder");
+ revalidatePath("/dashboard/spaces");
return {
id: idToUse,
diff --git a/apps/web/app/api/upload/utils.ts b/apps/web/app/api/upload/utils.ts
index 4f699a6da..b9a7e295d 100644
--- a/apps/web/app/api/upload/utils.ts
+++ b/apps/web/app/api/upload/utils.ts
@@ -7,8 +7,8 @@ export function parseVideoIdOrFileKey(
fileKey: string;
},
) {
- let videoId;
- let subpath;
+ let videoId: string;
+ let subpath: string;
if ("fileKey" in input) {
const [_, _videoId, ...subpathParts] = input.fileKey.split("/");