feat: recorded import grants, unclaimed creators and claiming
Pull request / title (pull_request) Successful in 1s
CI / test (pull_request) Successful in 1m19s
CI / image (apps/api/Dockerfile, t5de-hub-api) (pull_request) Skipped
CI / image (apps/web/Dockerfile, t5de-hub-web) (pull_request) Skipped

Admins record consent for IMVU creators without an account; their products
belong to a placeholder (imvu_<ID>) until they link the account and claim
them. Proof by a tagline code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
dhkatzandClaude Opus 5.5 committed 2026-11-07 11:12:26 -08:00
1 parent e6a97be894
commit 64b9658bad
18 files changed
+5222 -26

No files matched your search

+71
View File
@@ -0,0 +1,71 @@
"use server";
// Recorded grants from the console (docs/imports.md): admins record consent for IMVU creators who won't make an
// account, prove it with a tagline code, and change or withdraw them until the creator claims them.
import { revalidatePath } from "next/cache";
import { api, ApiError, unwrap } from "@/lib/api";
import { attempt, field, type ActionState } from "@/lib/actions";
import { productIDs } from "@/lib/imvu";
const done = () => revalidatePath("/console/imports");
/** Records a creator's consent: a grant for an unclaimed creator standing in for their IMVU account. */
export async function recordGrant(_: ActionState, form: FormData): Promise<ActionState> {
const scope = field(form, "scope") === "products" ? "products" : "shop";
const list = productIDs(field(form, scope === "products" ? "products" : "exclude"));
if (!list) return { error: "Products are IMVU product IDs or shop links, separated by spaces, commas or lines." };
return attempt(async () => {
const r = unwrap(
await api.console.imports.grants.post({
catalog: field(form, "catalog"),
imvu: field(form, "imvu"),
scope,
...(scope === "products" ? { products: list } : { exclude: list }),
listed: form.get("listed") === "on",
evidence: field(form, "evidence"),
}),
);
done();
return `Recorded for ${r.grant.imvuName}. The catalog's team accepts it before anything is imported.`;
});
}
/** Proof without an account: a code for the creator's tagline, then checking it. */
export async function grantProof(_: ActionState, form: FormData): Promise<ActionState> {
const id = field(form, "id");
return attempt(async () => {
if (field(form, "intent") === "check") {
unwrap(await api.console.imports.grants({ id }).proof.check.post());
done();
return "Proven: the code is in their tagline. They can take it out now.";
}
const { code } = unwrap(await api.console.imports.grants({ id }).proof.post());
done();
return `Send them this code to put in their IMVU tagline: ${code}`;
});
}
/** Changes what a recorded grant covers, or withdraws it. */
export async function changeRecorded(_: ActionState, form: FormData): Promise<ActionState> {
const id = field(form, "id");
return attempt(async () => {
if (field(form, "intent") === "withdraw") {
const reason = field(form, "reason") || "Withdrawn at the creator's request.";
const r = unwrap(await api.imports.grants({ id }).delete({ reason }));
done();
return r.withdrawn.length ? `Withdrawn. ${r.withdrawn.length} imported products were taken away.` : "Withdrawn.";
}
const scope = field(form, "scope") === "products" ? "products" : "shop";
const list = productIDs(field(form, "list"));
if (!list) throw new ApiError(400, "invalid", "Products are IMVU product IDs or shop links.");
const r = unwrap(
await api.imports.grants({ id }).patch({
...(scope === "products" ? { products: list } : { exclude: list }),
listed: form.get("listed") === "on",
}),
);
done();
return r.withdrawn.length
? `Saved. ${r.withdrawn.length} imported products it no longer covers were taken away.`
: "Saved.";
});
}
+291
View File
@@ -0,0 +1,291 @@
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { ActionForm, SubmitButton } from "@/components/forms";
import { PageHeader, Tag } from "@/components/status";
import { DateTime } from "@/components/time";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { NativeSelect, NativeSelectOption } from "@/components/ui/native-select";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { Textarea } from "@/components/ui/textarea";
import { api, unwrap } from "@/lib/api";
import { ConsoleNav, requireConsole } from "../console-nav";
import { changeRecorded, grantProof, recordGrant } from "./actions";
export const metadata: Metadata = { title: "Imports" };
type Recorded = Awaited<ReturnType<typeof load>>["grants"][number];
const load = async () => unwrap(await api.console.imports.get());
const statusTone = {
pending: "strong",
active: "online",
declined: "neutral",
suspended: "danger",
withdrawn: "neutral",
} as const;
const imvuShop = (id: number) => `https://www.imvu.com/shop/web_search.php?manufacturers_id=${id}`;
export default async function ConsoleImports() {
const { console: c } = await requireConsole("/console/imports");
if (!c.sections.includes("imports")) notFound();
const data = await load();
const open = data.grants.filter((g) => g.status !== "withdrawn" && g.status !== "declined");
const ended = data.grants.filter((g) => g.status === "withdrawn" || g.status === "declined");
return (
<>
<PageHeader title="Imports">
Consent recorded for IMVU creators who won&apos;t make an account, and the creators people ask for most.
</PageHeader>
<ConsoleNav />
<div className="space-y-6">
<Card>
<CardHeader>
<CardTitle>Record a Creator&apos;s Consent</CardTitle>
<CardDescription>
For creators who agreed to have their IMVU products on T5DE but won&apos;t make an account. Their products
belong to a placeholder until they join and link that IMVU account, when they can claim them. The
catalog&apos;s team still accepts it.
</CardDescription>
</CardHeader>
<CardContent>
{data.catalogs.length === 0 ? (
<p className="text-sm text-muted-foreground">No catalog takes imports yet.</p>
) : (
<ActionForm action={recordGrant} className="max-w-2xl space-y-4">
<div className="grid gap-4 sm:grid-cols-2">
<Field>
<FieldLabel htmlFor="imvu">IMVU creator</FieldLabel>
<Input id="imvu" name="imvu" required maxLength={64} placeholder="Username or account ID" />
</Field>
<Field>
<FieldLabel htmlFor="catalog">Catalog</FieldLabel>
<NativeSelect id="catalog" name="catalog">
{data.catalogs.map((k) => (
<NativeSelectOption key={k.id} value={k.id}>
{k.name}
</NativeSelectOption>
))}
</NativeSelect>
</Field>
</div>
<fieldset className="space-y-2">
<legend className="mb-2 text-sm font-medium">What they agreed to</legend>
<label className="flex items-center gap-2 text-sm">
<input type="radio" name="scope" value="shop" defaultChecked />
Their whole shop, including new products (leave some out below)
</label>
<label className="flex items-center gap-2 text-sm">
<input type="radio" name="scope" value="products" />
Only the products listed below
</label>
</fieldset>
<div className="grid gap-4 sm:grid-cols-2">
<Field>
<FieldLabel htmlFor="exclude">Leave out (whole shop)</FieldLabel>
<Textarea
id="exclude"
name="exclude"
rows={2}
placeholder="IMVU product IDs or shop links"
className="font-mono text-xs"
/>
</Field>
<Field>
<FieldLabel htmlFor="products">Products (only these)</FieldLabel>
<Textarea
id="products"
name="products"
rows={2}
placeholder="IMVU product IDs or shop links"
className="font-mono text-xs"
/>
</Field>
</div>
<label className="flex items-center gap-2 text-sm">
<input type="checkbox" name="listed" defaultChecked />
Listed (shown in search; unlisted ones work by link)
</label>
<Field>
<FieldLabel htmlFor="evidence">How they agreed</FieldLabel>
<Textarea
id="evidence"
name="evidence"
rows={2}
required
maxLength={1000}
placeholder="Where and when, e.g. Discord DM, 2026-11-07"
/>
<FieldDescription>
They agreed to: &ldquo;{data.consent.text}&rdquo; You can prove it afterwards with a code in their
IMVU tagline.
</FieldDescription>
</Field>
<SubmitButton pendingLabel="Recording…">Record</SubmitButton>
</ActionForm>
)}
</CardContent>
</Card>
{open.length > 0 && (
<Card>
<CardHeader>
<CardTitle>Recorded Grants</CardTitle>
</CardHeader>
<CardContent className="divide-y">
{open.map((g) => (
<RecordedRow key={g.id} grant={g} />
))}
</CardContent>
</Card>
)}
<Card>
<CardHeader>
<CardTitle>Most Asked For</CardTitle>
<CardDescription>
IMVU creators whose products T5DE users ask for: whom it&apos;s worth asking.
</CardDescription>
</CardHeader>
<CardContent>
{data.creators.length === 0 ? (
<p className="text-sm text-muted-foreground">Nobody has asked for anything yet.</p>
) : (
<Table>
<TableHeader>
<TableRow>
<TableHead>IMVU creator</TableHead>
<TableHead className="text-right">People</TableHead>
<TableHead className="text-right">Products</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{data.creators.map((k) => (
<TableRow key={k.imvuCreator}>
<TableCell>
<a
href={imvuShop(k.imvuCreator)}
target="_blank"
rel="noreferrer"
className="underline-offset-4 hover:underline"
>
{k.name || `IMVU account ${k.imvuCreator}`}
</a>
</TableCell>
<TableCell className="text-right tabular-nums">{k.people}</TableCell>
<TableCell className="text-right tabular-nums">{k.products}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
)}
</CardContent>
</Card>
{ended.length > 0 && (
<details className="text-sm">
<summary className="cursor-pointer text-muted-foreground hover:text-foreground">Ended</summary>
<ul className="mt-2 divide-y">
{ended.map((g) => (
<li key={g.id} className="py-2">
{g.imvuName || g.imvuId} → {g.catalogName} <Tag tone={statusTone[g.status]}>{g.status}</Tag>{" "}
<span className="text-muted-foreground">{g.statusReason}</span>
</li>
))}
</ul>
</details>
)}
</div>
</>
);
}
function RecordedRow({ grant: g }: { grant: Recorded }) {
const list = g.scope === "products" ? g.products : g.exclude;
return (
<div className="space-y-3 py-4 first:pt-0 last:pb-0">
<div className="flex flex-wrap items-center gap-2 text-sm">
<span className="font-medium">{g.imvuName || `IMVU account ${g.imvuId}`}</span>
<span className="text-muted-foreground">(IMVU {g.imvuId}) to</span>
<span className="font-medium">{g.catalogName}</span>
<Tag tone={statusTone[g.status]}>{g.status === "pending" ? "waiting for the catalog" : g.status}</Tag>
{g.consentProven ? <Tag tone="online">proven</Tag> : <Tag>not proven</Tag>}
{g.claimed && <Tag tone="strong">claimed</Tag>}
</div>
<p className="text-sm text-muted-foreground">
{g.evidence} · recorded by {g.recordedBy || "someone"} on <DateTime iso={g.createdAt} dateOnly />
</p>
<p className="text-sm">
{g.scope === "shop"
? `The whole shop${g.exclude.length ? `, less ${g.exclude.length} left out` : ""}.`
: `${g.products.length} chosen product${g.products.length === 1 ? "" : "s"}.`}{" "}
{g.listed ? "Listed." : "Unlisted."}
</p>
{g.claimed ? (
<p className="text-sm text-muted-foreground">The creator claimed it: they manage it now.</p>
) : (
<>
{!g.consentProven && (
<ActionForm action={grantProof} fields={{ id: g.id }}>
<div className="flex flex-wrap items-center gap-2 text-sm">
{g.proofCode ? (
<>
<span>
Code for their tagline: <code className="font-mono">{g.proofCode}</code>
</span>
<SubmitButton name="intent" value="check" size="sm" variant="outline" pendingLabel="Checking…">
Check their tagline
</SubmitButton>
</>
) : (
<SubmitButton name="intent" value="code" size="sm" variant="outline" pendingLabel="Making one…">
Prove it with a tagline code
</SubmitButton>
)}
</div>
</ActionForm>
)}
<ActionForm action={changeRecorded} fields={{ id: g.id, scope: g.scope }} className="max-w-2xl space-y-2">
<Field>
<FieldLabel htmlFor={`list-${g.id}`}>{g.scope === "shop" ? "Left out" : "Products"}</FieldLabel>
<Textarea
id={`list-${g.id}`}
name="list"
rows={2}
defaultValue={list.join("\n")}
className="font-mono text-xs"
/>
</Field>
<label className="flex items-center gap-2 text-sm">
<input type="checkbox" name="listed" defaultChecked={g.listed} />
Listed
</label>
<div className="flex flex-wrap gap-2">
<Input
name="reason"
maxLength={500}
placeholder="Reason (if withdrawing)"
aria-label="Reason"
className="max-w-xs"
/>
<SubmitButton name="intent" value="save" variant="outline" pendingLabel="Saving…">
Save
</SubmitButton>
<SubmitButton
name="intent"
value="withdraw"
variant="outline"
pendingLabel="Withdrawing…"
confirm="Withdraw? Its imported products are taken away from everyone who has them."
>
Withdraw
</SubmitButton>
</div>
</ActionForm>
</>
)}
</div>
);
}