vault-video-processor / src /features /vault /actions /refresh-metadata.ts
dvijaykrishnan's picture
feat: Implement social ingestion and video metadata refresh with schema updates and UI enhancements.
256e9b3
Raw
History Blame Contribute Delete
1.49 kB
"use server";
import { ShowcaseService } from "../services/showcase.service";
import { auth } from "@/lib/auth";
import { headers } from "next/headers";
import { revalidatePath } from "next/cache";
/**
* Server action to refresh video metadata (dimensions, title, etc.)
*/
export async function refreshMetadataAction(videoId: string) {
try {
const session = await auth.api.getSession({
headers: await headers()
});
if (!session?.user) {
return { success: false, error: "Unauthorized" };
}
// Ownership check is handled inside ShowcaseService.refreshMetadata if we want,
// but let's do a quick check here too to be safe.
// For simplicity, we'll let the service handle the query and we can check if it belongs to the user or is public.
await ShowcaseService.refreshMetadata(videoId);
// Revalidate the pages where this video appears
revalidatePath(`/showcase/${videoId}`);
revalidatePath(`/showcase/${videoId}/moderate`);
// We'd ideally revalidate the public vault too, but we need the creatorSlug.
// ShowcaseService.refreshMetadata already handles the cache invalidation.
return { success: true };
} catch (error) {
console.error("[refreshMetadataAction] Error:", error);
return {
success: false,
error: error instanceof Error ? error.message : "Failed to refresh metadata"
};
}
}