feat(video-assets): add full video asset system (uploads, downloads, @mentions, and cleanup/billing integration)

This commit is contained in:
Yusuf İpek
2026-02-25 18:34:03 +03:00
parent 6eea327083
commit 9ce033d306
32 changed files with 3524 additions and 231 deletions
+20 -8
View File
@@ -142,16 +142,28 @@ async function findReferencedVideoIds(videoIds: string[]): Promise<Set<string>>
const referenced = new Set<string>();
for (const group of chunk(videoIds, CHUNK_SIZE)) {
const rows = await db.videoVersion.findMany({
where: {
providerId: 'bunny',
videoId: { in: group },
},
select: { videoId: true },
});
rows.forEach((row) => {
const [versionRows, assetRows] = await Promise.all([
db.videoVersion.findMany({
where: {
providerId: 'bunny',
videoId: { in: group },
},
select: { videoId: true },
}),
db.videoAsset.findMany({
where: {
provider: 'BUNNY',
providerVideoId: { in: group },
},
select: { providerVideoId: true },
}),
]);
versionRows.forEach((row) => {
if (row.videoId) referenced.add(row.videoId);
});
assetRows.forEach((row) => {
if (row.providerVideoId) referenced.add(row.providerVideoId);
});
}
return referenced;
+8 -1
View File
@@ -79,7 +79,7 @@ async function findReferencedUrls(urls: string[]): Promise<Set<string>> {
}).userFeedbackScreenshot;
for (const group of chunk(urls, CHUNK_SIZE)) {
const [commentRows, feedbackRows, feedbackAttachmentRows] = await Promise.all([
const [commentRows, feedbackRows, feedbackAttachmentRows, assetRows] = await Promise.all([
db.comment.findMany({
where: {
OR: [{ voiceUrl: { in: group } }, { imageUrl: { in: group } }],
@@ -99,6 +99,10 @@ async function findReferencedUrls(urls: string[]): Promise<Set<string>> {
select: { url: true },
})
: Promise.resolve([] as Array<{ url: string }>),
db.videoAsset.findMany({
where: { sourceUrl: { in: group } },
select: { sourceUrl: true },
}),
]);
for (const row of commentRows) {
@@ -111,6 +115,9 @@ async function findReferencedUrls(urls: string[]): Promise<Set<string>> {
for (const row of feedbackAttachmentRows) {
if (row.url) referenced.add(row.url);
}
for (const row of assetRows) {
if (row.sourceUrl) referenced.add(row.sourceUrl);
}
}
return referenced;