feat: whole shops listed on IMVU, and GET /imports/available (#16)
Release / release (push) Successful in 4s
CI / test (push) Successful in 1m35s
CI / image (apps/api/Dockerfile, t5de-hub-api) (push) Successful in 6s
CI / image (apps/web/Dockerfile, t5de-hub-web) (push) Successful in 14s

Co-authored-by: dhkatz <[email protected]>
This commit was merged in pull request #16.
This commit is contained in:
dhkatz authored and dhkatz committed 2026-11-08 00:51:00 +00:00
1 parent 8f6dacba10
commit efc7d6b808
15 files changed
+4954 -20

No files matched your search

+36
View File
@@ -403,6 +403,9 @@ export function createApp({
consentKind: r.grant.consentKind as "verified" | "recorded",
consentProven: r.grant.proofCheckedAt !== null, // recorded, and the creator put the code in their tagline
consentVersion: r.grant.consentVersion,
// A whole shop: when the hub last listed its products on IMVU (null: not yet), and how many IMVU listed.
shopListedAt: r.grant.shopListedAt?.toISOString() ?? null,
shopListed: r.grant.shopListed,
status: r.grant.status as "pending" | "active" | "declined" | "suspended" | "withdrawn",
statusReason: r.grant.statusReason,
createdAt: r.grant.createdAt.toISOString(),
@@ -2103,6 +2106,7 @@ export function createApp({
await need(me, "import:grant-on-behalf", hubScope);
}
const { grant, withdrawn } = await productCall(() => imports.updateGrant(g.id, body));
if (grant.status === "active" && grant.scope === "shop" && !grant.shopListedAt) imports.listShopSoon(grant.id);
await audited(
me,
"import.grant_change",
@@ -2130,6 +2134,7 @@ export function createApp({
const decision = params.decision;
const reason = body?.reason?.trim() ?? "";
const done = await productCall(() => imports.decide(g.id, decision, me.id, reason));
if (done.grant.status === "active" && done.grant.scope === "shop") imports.listShopSoon(g.id);
await audited(
me,
`import.grant_${decision}`,
@@ -2173,6 +2178,37 @@ export function createApp({
},
{ signedIn: true, body: t.Optional(t.Object({ reason: t.Optional(t.String({ maxLength: 500 })) })) },
)
.post(
"/imports/grants/:id/list",
async ({ me, params }) => {
const g = await productCall(() => imports.grant(params.id));
if (g.creatorId !== me.id) await need(me, "import:run", catalogScope(g.catalogId));
if (g.status !== "active" || g.scope !== "shop") throw new Problem(409, "not_shop", "Only an active grant of a whole shop is listed.");
// A listing is a few large IMVU calls.
if (!limiter.allow(`shop-list:${g.id}`, 3, 60 * 60 * 1000)) throw new Problem(429, "rate_limited", "Listed recently. Try again in a while.");
const done = await productCall(() => imvuSafe(() => imports.listShop(g.id)));
return { grant: grantView({ grant: await imports.grant(g.id) }), ...done };
},
{ signedIn: true },
)
// What T5DE has of IMVU products and shops (for the proxy's "Get on T5DE" in IMVU's shop). Anyone; signed in, it
// also says what the person asked for, and adult products show only to adult accounts.
.get(
"/imports/available",
async ({ person, query }) => {
const list = (v?: string) => {
const ids = (v ?? "").split(",").filter(Boolean).map(Number);
if (ids.length > 100 || ids.some((n) => !Number.isSafeInteger(n) || n <= 0))
throw new Problem(400, "invalid", "Give up to 100 IMVU IDs, separated by commas.");
return ids;
};
const products = list(query.products);
const creators = list(query.creators);
const viewer = person ? { id: person.id, adult: await personAdult(person) } : undefined;
return imports.available(products, creators, viewer);
},
{ query: t.Object({ products: t.Optional(t.String({ maxLength: 2000 })), creators: t.Optional(t.String({ maxLength: 2000 })) }) },
)
.post(
"/imports/requests",
async ({ me, body }) => {