feat: name downloaded file after the video title and add a back-to-home link
The download endpoint served files under their internal uuid-based storage name; it now builds the Content-Disposition filename from the probed video title (persisted on submit) with the original extension, falling back to the old behavior when no title is available. The status page also gets an always-visible link back to the homepage. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+7
-3
@@ -13,13 +13,17 @@ export async function createToken(downloadId: string): Promise<string> {
|
||||
|
||||
export async function validateToken(
|
||||
token: string
|
||||
): Promise<{ downloadId: string; filePath: string } | null> {
|
||||
): Promise<{ downloadId: string; filePath: string; title: string | null } | null> {
|
||||
const record = await prisma.downloadToken.findUnique({
|
||||
where: { token },
|
||||
include: { download: { select: { id: true, filePath: true } } },
|
||||
include: { download: { select: { id: true, filePath: true, title: true } } },
|
||||
})
|
||||
if (!record) return null
|
||||
if (record.expiresAt < new Date()) return null
|
||||
if (!record.download.filePath) return null
|
||||
return { downloadId: record.download.id, filePath: record.download.filePath }
|
||||
return {
|
||||
downloadId: record.download.id,
|
||||
filePath: record.download.filePath,
|
||||
title: record.download.title,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user