Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dev": "pnpm -w cap-setup && dotenv -e ../../.env -- pnpm run preparescript && dotenv -e ../../.env -- pnpm tauri dev",
"build:tauri": "dotenv -e ../../.env -- pnpm run preparescript && dotenv -e ../../.env -- pnpm tauri build",
"preparescript": "node scripts/prepare.js",
"localdev": "dotenv -e ../../.env -- vinxi dev --port 3001",
"localdev": "dotenv -e ../../.env -- vinxi dev --port 3002",
"build": "vinxi build",
"tauri": "tauri"
},
Expand Down Expand Up @@ -54,7 +54,7 @@
"@ts-rest/core": "^3.52.1",
"@types/react-tooltip": "^4.2.4",
"cva": "npm:class-variance-authority@^0.7.0",
"effect": "^3.17.7",
"effect": "^3.17.13",
"mp4box": "^0.5.2",
"posthog-js": "^1.215.3",
"solid-js": "^1.9.3",
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mainBinaryName": "Cap - Development",
"build": {
"beforeDevCommand": "pnpm localdev",
"devUrl": "http://localhost:3001",
"devUrl": "http://localhost:3002",
"beforeBuildCommand": "pnpm turbo build --filter @cap/desktop",
"frontendDist": "../.output/public"
},
Expand Down
2 changes: 1 addition & 1 deletion apps/discord-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"scripts": {
"deploy": "wrangler deploy",
"dev": "wrangler dev",
"bot-dev": "wrangler dev",
"start": "wrangler dev",
"test": "vitest",
"cf-typegen": "wrangler types"
Expand Down
1 change: 0 additions & 1 deletion apps/tasks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"main": "src/index.ts",
"scripts": {
"start": "node dist/src/index.js",
"dev": "ts-node src/index.ts",
"build": "tsc",
"start:dist": "node dist/src/index.js",
"test": "jest",
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/caps/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import {
spaceVideos,
videos,
} from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

interface ShareCapParams {
capId: string;
capId: Video.VideoId;
spaceIds: string[];
public?: boolean;
}
Expand Down
7 changes: 4 additions & 3 deletions apps/web/actions/folders/moveVideoToFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { folders, spaceVideos, videos } from "@cap/database/schema";
import type { Folder, Video } from "@cap/web-domain";
import { and, eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

Expand All @@ -11,8 +12,8 @@ export async function moveVideoToFolder({
folderId,
spaceId,
}: {
videoId: string;
folderId: string | null;
videoId: Video.VideoId;
folderId: Folder.FolderId | null;
spaceId?: string | null;
}) {
const user = await getCurrentUser();
Expand All @@ -23,7 +24,7 @@ export async function moveVideoToFolder({

// Get the current video to know its original folder
const [currentVideo] = await db()
.select({ folderId: videos.folderId })
.select({ folderId: videos.folderId, id: videos.id })
.from(videos)
.where(eq(videos.id, videoId));

Expand Down
5 changes: 3 additions & 2 deletions apps/web/actions/folders/updateFolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { folders } from "@cap/database/schema";
import type { Folder } from "@cap/web-domain";
import { and, eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

Expand All @@ -12,10 +13,10 @@ export async function updateFolder({
color,
parentId,
}: {
folderId: string;
folderId: Folder.FolderId;
name?: string;
color?: "normal" | "blue" | "red" | "yellow";
parentId?: string | null;
parentId?: Folder.FolderId | null;
}) {
const user = await getCurrentUser();
if (!user || !user.activeOrganizationId)
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organizations/add-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import {
sharedVideos,
videos,
} from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function addVideosToOrganization(
organizationId: string,
videoIds: string[],
videoIds: Video.VideoId[],
) {
try {
const user = await getCurrentUser();
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/organizations/remove-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import {
sharedVideos,
videos,
} from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function removeVideosFromOrganization(
organizationId: string,
videoIds: string[],
videoIds: Video.VideoId[],
) {
try {
const user = await getCurrentUser();
Expand Down
67 changes: 0 additions & 67 deletions apps/web/actions/screenshots/get-screenshot.ts

This file was deleted.

6 changes: 5 additions & 1 deletion apps/web/actions/spaces/add-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { nanoId } from "@cap/database/helpers";
import { spaces, spaceVideos, videos } from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function addVideosToSpace(spaceId: string, videoIds: string[]) {
export async function addVideosToSpace(
spaceId: string,
videoIds: Video.VideoId[],
) {
try {
const user = await getCurrentUser();

Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/spaces/remove-videos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { folders, spaceVideos, videos } from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import { and, eq, inArray } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function removeVideosFromSpace(
spaceId: string,
videoIds: string[],
videoIds: Video.VideoId[],
) {
try {
const user = await getCurrentUser();
Expand Down
7 changes: 4 additions & 3 deletions apps/web/actions/video/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { nanoId } from "@cap/database/helpers";
import { s3Buckets, videos, videoUploads } from "@cap/database/schema";
import { buildEnv, NODE_ENV, serverEnv } from "@cap/env";
import { userIsPro } from "@cap/utils";
import { type Folder, Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
import { dub } from "@/utils/dub";
Expand Down Expand Up @@ -156,14 +157,14 @@ export async function createVideoAndGetUploadUrl({
isUpload = false,
folderId,
}: {
videoId?: string;
videoId?: Video.VideoId;
duration?: number;
resolution?: string;
videoCodec?: string;
audioCodec?: string;
isScreenshot?: boolean;
isUpload?: boolean;
folderId?: string;
folderId?: Folder.FolderId;
}) {
const user = await getCurrentUser();

Expand Down Expand Up @@ -211,7 +212,7 @@ export async function createVideoAndGetUploadUrl({
}
}

const idToUse = videoId || nanoId();
const idToUse = Video.VideoId.make(videoId || nanoId());

const bucket = await createBucketProvider(customBucket);

Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/videos/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { videos } from "@cap/database/schema";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Bug: ignoring per‑video bucket causes broken URLs in multi‑bucket setups.

Join s3Buckets and pass the matched bucket to createBucketProvider, like other actions.

-import { videos } from "@cap/database/schema";
+import { s3Buckets, videos } from "@cap/database/schema";
@@
-const query = await db().select().from(videos).where(eq(videos.id, videoId));
+const query = await db()
+  .select({ video: videos, bucket: s3Buckets })
+  .from(videos)
+  .leftJoin(s3Buckets, eq(videos.bucket, s3Buckets.id))
+  .where(eq(videos.id, videoId));
@@
-const video = query[0];
+const { video, bucket } = query[0];
@@
-const bucketProvider = await createBucketProvider();
-const videoKey = `${video.ownerId}/${videoId}/result.mp4`;
+const bucketProvider = await createBucketProvider(bucket);
+const videoKey = `${video.ownerId}/${video.id}/result.mp4`;

Also applies to: 18-19, 24-25, 33-37

🤖 Prompt for AI Agents
In apps/web/actions/videos/download.ts around lines 5 and additionally 18-19,
24-25, 33-37, the code ignores per-video bucket selection causing broken URLs in
multi-bucket setups; update the logic to join s3Buckets and locate the specific
bucket matching the video's bucketId, then pass that matched bucket object into
createBucketProvider (same pattern as other actions) so the provider constructs
correct URLs; ensure you handle the case where no matching bucket is found
(error or fallback) and use the matched bucket for all createBucketProvider
calls in the listed lines.

import type { Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { createBucketProvider } from "@/utils/s3";

export async function downloadVideo(videoId: string) {
export async function downloadVideo(videoId: Video.VideoId) {
const user = await getCurrentUser();

if (!user || !videoId) {
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/videos/edit-date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { videos } from "@cap/database/schema";
import type { VideoMetadata } from "@cap/database/types";
import type { Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function editDate(videoId: string, date: string) {
export async function editDate(videoId: Video.VideoId, date: string) {
const user = await getCurrentUser();

if (!user || !date || !videoId) {
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/videos/edit-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { videos } from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";

export async function editTitle(videoId: string, title: string) {
export async function editTitle(videoId: Video.VideoId, title: string) {
const user = await getCurrentUser();

if (!user || !title || !videoId) {
Expand Down
4 changes: 2 additions & 2 deletions apps/web/actions/videos/edit-transcript.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"use server";

import { GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3";
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { s3Buckets, videos } from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
import { createBucketProvider } from "@/utils/s3";

export async function editTranscriptEntry(
videoId: string,
videoId: Video.VideoId,
entryId: number,
newText: string,
): Promise<{ success: boolean; message: string }> {
Expand Down
5 changes: 3 additions & 2 deletions apps/web/actions/videos/get-og-image.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { db } from "@cap/database";
import { s3Buckets, videos } from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { ImageResponse } from "next/og";
import { createBucketProvider } from "@/utils/s3";

export async function generateVideoOgImage(videoId: string) {
export async function generateVideoOgImage(videoId: Video.VideoId) {
const videoData = await getData(videoId);

if (!videoData) {
Expand Down Expand Up @@ -145,7 +146,7 @@ export async function generateVideoOgImage(videoId: string) {
);
}

async function getData(videoId: string) {
async function getData(videoId: Video.VideoId) {
const query = await db()
.select({
video: videos,
Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/videos/get-transcript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { s3Buckets, videos } from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import { eq } from "drizzle-orm";
import { createBucketProvider } from "@/utils/s3";

export async function getTranscript(
videoId: string,
videoId: Video.VideoId,
): Promise<{ success: boolean; content?: string; message: string }> {
const user = await getCurrentUser();

Expand Down
3 changes: 2 additions & 1 deletion apps/web/actions/videos/new-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { db } from "@cap/database";
import { getCurrentUser } from "@cap/database/auth/session";
import { nanoId } from "@cap/database/helpers";
import { comments } from "@cap/database/schema";
import type { Video } from "@cap/web-domain";
import { revalidatePath } from "next/cache";
import { createNotification } from "@/lib/Notification";

export async function newComment(data: {
content: string;
videoId: string;
videoId: Video.VideoId;
type: "text" | "emoji";
parentCommentId: string;
}) {
Expand Down
Loading
Loading