-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Web recorder on tab change performance improvements
- Loading branch information
1 parent
73dd21c
commit 0efb074
Showing
6 changed files
with
196 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { type NextRequest } from "next/server"; | ||
import { getCurrentUser } from "@cap/database/auth/session"; | ||
import { videos } from "@cap/database/schema"; | ||
import { db } from "@cap/database"; | ||
import { eq } from "drizzle-orm"; | ||
|
||
export async function PUT(request: NextRequest) { | ||
const user = await getCurrentUser(); | ||
const { videoId, metadata } = await request.json(); | ||
const userId = user?.id as string; | ||
|
||
if (!user || !videoId || !metadata) { | ||
console.error("Missing required data in /api/video/metadata/route.ts"); | ||
|
||
return new Response(JSON.stringify({ error: true }), { | ||
status: 401, | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
} | ||
|
||
const query = await db.select().from(videos).where(eq(videos.id, videoId)); | ||
|
||
if (query.length === 0) { | ||
return new Response(JSON.stringify({ error: true }), { | ||
status: 401, | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
} | ||
|
||
const ownerId = query[0].ownerId; | ||
|
||
if (ownerId !== userId) { | ||
return new Response(JSON.stringify({ error: true }), { | ||
status: 401, | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
} | ||
|
||
await db | ||
.update(videos) | ||
.set({ | ||
metadata: metadata, | ||
}) | ||
.where(eq(videos.id, videoId)); | ||
|
||
return new Response( | ||
JSON.stringify({ | ||
status: 200, | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters