CI / test (push) Successful in 1m4s
A creator deletes a product: it's no longer listed and nobody new can get it, while people who have it keep it (its page, files and library entries stay, and rooms keep showing it), as old revisions stay available. Moderation removes one everywhere, with a reason: its page and files answer 410, and it leaves libraries and rooms. Both are on the product's page and in the audit log. Co-Authored-By: Claude Opus 5.5 <[email protected]>
15 lines
550 B
TypeScript
15 lines
550 B
TypeScript
import "server-only";
|
|
import { notFound } from "next/navigation";
|
|
import { api, ApiError, unwrap, type ProductPage } from "@/lib/api";
|
|
|
|
/** The product, or not found (also when it's adult and the visitor can't see adult products, or it was removed). */
|
|
export async function loadProduct(id: string): Promise<ProductPage> {
|
|
if (!/^[a-z2-7]{10}$/.test(id)) notFound();
|
|
try {
|
|
return unwrap(await api.products({ id }).get());
|
|
} catch (e) {
|
|
if (e instanceof ApiError && (e.status === 404 || e.status === 410)) notFound();
|
|
throw e;
|
|
}
|
|
}
|