feat(imports): Access Pass products through the importer's signed-in account #20

Merged
dhkatz merged 2 commits from feat/importer-signed-in into main 2026-11-08 16:10:35 +00:00
12 changed files with 4852 additions and 38 deletions
Showing only changes of commit e2308aa0aa - Show all commits

No files matched your search

+52 -1
View File
@@ -406,17 +406,27 @@ export function createApp({
// A whole shop: when the hub last listed its products on IMVU (null: not yet), and how many IMVU listed. // 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, shopListedAt: r.grant.shopListedAt?.toISOString() ?? null,
shopListed: r.grant.shopListed, shopListed: r.grant.shopListed,
shopListedSignedIn: r.grant.shopListedSignedIn,
status: r.grant.status as "pending" | "active" | "declined" | "suspended" | "withdrawn", status: r.grant.status as "pending" | "active" | "declined" | "suspended" | "withdrawn",
statusReason: r.grant.statusReason, statusReason: r.grant.statusReason,
createdAt: r.grant.createdAt.toISOString(), createdAt: r.grant.createdAt.toISOString(),
decidedAt: r.grant.decidedAt?.toISOString() ?? null, decidedAt: r.grant.decidedAt?.toISOString() ?? null,
}); });
/** A product as an importer's IMVU account sees it. */
const seenProduct = t.Object({
id: t.Integer({ minimum: 1 }),
name: t.String({ maxLength: 200 }),
rating: t.Union([t.Literal("general"), t.Literal("adult")]),
creatorId: t.Integer({ minimum: 1 }),
creatorName: t.String({ maxLength: 64 }),
purchasable: t.Boolean(),
});
const jobView = (j: typeof schema.importJob.$inferSelect) => ({ const jobView = (j: typeof schema.importJob.$inferSelect) => ({
id: j.id, id: j.id,
grant: j.grantId, grant: j.grantId,
imvuProduct: j.imvuProduct, imvuProduct: j.imvuProduct,
kind: j.kind as "import" | "recheck", kind: j.kind as "import" | "recheck" | "list",
status: j.status as "queued" | "claimed" | "done" | "failed", status: j.status as "queued" | "claimed" | "done" | "failed",
imvuRevision: j.imvuRevision, imvuRevision: j.imvuRevision,
reason: j.reason, reason: j.reason,
@@ -1943,6 +1953,45 @@ export function createApp({
}, },
{ body: t.Object({ imvuRevision: t.Integer({ minimum: 1 }) }) }, { body: t.Object({ imvuRevision: t.Integer({ minimum: 1 }) }) },
) )
.post(
"/importer/jobs/:id/listing",
async ({ request, params, body }) => {
const c = await imports.importerFor(request.headers.get("authorization"));
if (!c) throw new Problem(401, "forbidden", "Not an importer of an approved catalog with imports on.");
return productCall(() => imports.reportListing(c, params.id, body.products));
},
{ body: t.Object({ products: t.Array(seenProduct, { maxItems: 10000 }) }) },
)
.post(
"/importer/jobs/:id/info",
async ({ request, params, body }) => {
const c = await imports.importerFor(request.headers.get("authorization"));
if (!c) throw new Problem(401, "forbidden", "Not an importer of an approved catalog with imports on.");
return productCall(() =>
imvuSafe(() =>
imports.reportInfo(c, params.id, {
id: 0,
found: body.found,
name: body.name ?? "",
rating: body.rating ?? "general",
creatorId: body.creatorId ?? 0,
creatorName: body.creatorName ?? "",
purchasable: body.purchasable ?? true,
}),
),
);
},
{
body: t.Object({
found: t.Boolean(),
name: t.Optional(t.String({ maxLength: 200 })),
rating: t.Optional(t.Union([t.Literal("general"), t.Literal("adult")])),
creatorId: t.Optional(t.Integer({ minimum: 1 })),
creatorName: t.Optional(t.String({ maxLength: 64 })),
purchasable: t.Optional(t.Boolean()),
}),
},
)
.post( .post(
"/importer/jobs/:id", "/importer/jobs/:id",
async ({ request, params, body }) => { async ({ request, params, body }) => {
@@ -1986,6 +2035,8 @@ export function createApp({
const c = await imports.importerFor(request.headers.get("authorization")); const c = await imports.importerFor(request.headers.get("authorization"));
if (!c) throw new Problem(401, "forbidden", "Not an importer of an approved catalog with imports on."); if (!c) throw new Problem(401, "forbidden", "Not an importer of an approved catalog with imports on.");
const a = await productCall(() => importers.report(c, params.id, body)); const a = await productCall(() => importers.report(c, params.id, body));
// An account signed in with Access Pass: list the catalog's whole shops with it (Access Pass products too).
if (body.state === "ok" && body.accessPass) await imports.queueListings(c.id);
return { account: importerAccountView(a) }; return { account: importerAccountView(a) };
}, },
{ {
+146 -19
View File
@@ -7,8 +7,22 @@ import { ImvuUnavailable, NoSuchImvuUser, type ImvuClient, type ImvuUser } from
import type { Signer } from "./keys"; import type { Signer } from "./keys";
import { BlockedUpload, checkFiles, newProductID, ProductError, type Catalog } from "./products"; import { BlockedUpload, checkFiles, newProductID, ProductError, type Catalog } from "./products";
const { catalog, catalogChange, fileBlock, hosting, imvuLink, imvuProductInfo, importGrant, importJob, importRequest, library, product, productRevision, user } = const {
schema; catalog,
catalogChange,
fileBlock,
hosting,
imvuLink,
imvuProductInfo,
importerAccount,
importGrant,
importJob,
importRequest,
library,
product,
productRevision,
user,
} = schema;
export type Grant = typeof importGrant.$inferSelect; export type Grant = typeof importGrant.$inferSelect;
export type Job = typeof importJob.$inferSelect; export type Job = typeof importJob.$inferSelect;
@@ -59,6 +73,23 @@ const imvuNameOf = sql<string | null>`coalesce(${imvuLink.username}, (select u.d
export const unclaimedUsername = (imvuId: number) => `imvu_${imvuId}`; export const unclaimedUsername = (imvuId: number) => `imvu_${imvuId}`;
/** Whether a grant covers an IMVU product (by its IMVU creator): active, the creator's, and in its scope. */ /** Whether a grant covers an IMVU product (by its IMVU creator): active, the creator's, and in its scope. */
/** A product as an importer's IMVU account sees it (docs/imports.md, "Access Pass products"). */
export type SeenProduct = { id: number; name: string; rating: string; creatorId: number; creatorName: string; purchasable: boolean };
/** Checks what an importer says it saw: null if it isn't a product. */
function checkSeen(p: SeenProduct): SeenProduct | null {
if (!Number.isSafeInteger(p.id) || p.id <= 0 || !Number.isSafeInteger(p.creatorId) || p.creatorId <= 0) return null;
if (p.rating !== "general" && p.rating !== "adult") return null;
return {
id: p.id,
name: String(p.name ?? "").trim().slice(0, 200),
rating: p.rating,
creatorId: p.creatorId,
creatorName: String(p.creatorName ?? "").trim().slice(0, 64),
purchasable: p.purchasable !== false,
};
}
export function covers(g: Grant, imvuProduct: number, creatorId: number): boolean { export function covers(g: Grant, imvuProduct: number, creatorId: number): boolean {
if (g.status !== "active" || creatorId !== g.imvuId) return false; if (g.status !== "active" || creatorId !== g.imvuId) return false;
return g.scope === "shop" ? !g.exclude.includes(imvuProduct) : g.products.includes(imvuProduct); return g.scope === "shop" ? !g.exclude.includes(imvuProduct) : g.products.includes(imvuProduct);
@@ -545,17 +576,24 @@ export class Imports {
listed = []; // the account is gone from IMVU: nothing to list (rechecks withdraw what was imported) listed = []; // the account is gone from IMVU: nothing to list (rechecks withdraw what was imported)
} }
const now = new Date(); const now = new Date();
for (let i = 0; i < listed.length; i += 500) { await this.keepSeen(
const rows = listed.slice(i, i + 500).map((p) => ({ listed.map((p) => ({ id: p.id, name: p.name, rating: p.adult ? "adult" : "general", creatorId: p.creatorId, creatorName: p.creatorName, purchasable: p.purchasable })),
id: p.id, now,
found: true, );
name: p.name, const [updated] = await this.db
creatorId: p.creatorId, .update(importGrant)
creatorName: p.creatorName, .set({ shopListedAt: now, shopListed: listed.length, shopListedSignedIn: false })
rating: p.adult ? "adult" : "general", .where(eq(importGrant.id, g.id))
purchasable: p.purchasable, .returning();
checkedAt: now, const queued = updated?.status === "active" && updated.scope === "shop" ? await this.queueCovered(updated) : 0;
})); if (updated) await this.queueListing(updated);
return { listed: listed.length, queued };
}
/** Keeps products' info as seen (by the hub's listing, or an importer's account), in batches. */
private async keepSeen(seen: SeenProduct[], now: Date) {
for (let i = 0; i < seen.length; i += 500) {
const rows = seen.slice(i, i + 500).map((p) => ({ ...p, found: true, checkedAt: now }));
await this.db await this.db
.insert(imvuProductInfo) .insert(imvuProductInfo)
.values(rows) .values(rows)
@@ -572,13 +610,97 @@ export class Imports {
}, },
}); });
} }
}
/**
* Queues a signed-in listing of a whole-shop grant's shop for its catalog's importer, if one of the importer's IMVU
* accounts signed in with Access Pass: IMVU lists Access Pass products only to them.
*/
async queueListing(g: Grant): Promise<boolean> {
if (g.status !== "active" || g.scope !== "shop") return false;
const [ap] = await this.db
.select({ id: importerAccount.id })
.from(importerAccount)
.where(and(eq(importerAccount.catalogId, g.catalogId), eq(importerAccount.state, "ok"), eq(importerAccount.accessPass, true)))
.limit(1);
if (!ap) return false;
const [j] = await this.db
.insert(importJob)
.values({ id: newProductID(), catalogId: g.catalogId, grantId: g.id, imvuProduct: g.imvuId, kind: "list" })
.onConflictDoNothing()
.returning();
return j !== undefined;
}
/**
* The importer lists a whole shop signed in (a "list" job): the products it saw are kept (only the grant's IMVU
* account's: an importer can't vouch for another creator's), and those not imported yet are queued.
*/
async reportListing(c: Catalog, jobId: string, products: SeenProduct[]): Promise<{ listed: number; queued: number }> {
const job = await this.claimedJob(c, jobId);
if (job.kind !== "list") throw new ProductError(409, "not_list", "That job isn't a shop listing.");
const g = await this.grant(job.grantId);
const seen = new Map<number, SeenProduct>();
for (const p of products) {
const ok = checkSeen(p);
if (ok && ok.creatorId === g.imvuId) seen.set(ok.id, ok);
}
const now = new Date();
await this.keepSeen([...seen.values()], now);
await this.db.update(importJob).set({ status: "done", reason: "", claimedAt: null }).where(eq(importJob.id, job.id));
const [updated] = await this.db const [updated] = await this.db
.update(importGrant) .update(importGrant)
.set({ shopListedAt: now, shopListed: listed.length }) .set({ shopListedAt: now, shopListed: seen.size, shopListedSignedIn: true })
.where(eq(importGrant.id, g.id)) .where(and(eq(importGrant.id, g.id), eq(importGrant.status, "active"), eq(importGrant.scope, "shop")))
.returning(); .returning();
const queued = updated?.status === "active" && updated.scope === "shop" ? await this.queueCovered(updated) : 0; const queued = updated ? await this.queueCovered(updated) : 0;
return { listed: listed.length, queued }; return { listed: seen.size, queued };
}
/**
* The importer says what its IMVU account sees of a claimed job's product, which IMVU hides from the hub (Access
* Pass products): kept, so the job can go on. What IMVU shows the hub publicly wins.
*/
async reportInfo(c: Catalog, jobId: string, seen: SeenProduct & { found: boolean }): Promise<{ rating: string | null; covered: boolean }> {
const job = await this.claimedJob(c, jobId);
if (job.kind === "list") throw new ProductError(409, "not_product", "That job is a shop listing.");
const g = await this.grant(job.grantId);
const answer = this.imvu ? await this.imvu.lookup(job.imvuProduct) : "hidden";
let info: ImvuInfo | undefined;
if (typeof answer !== "string") info = await this.info(job.imvuProduct, true);
else if (!seen.found) {
// Gone, as the importer's account sees it too: rechecks withdraw it.
const now = new Date();
await this.db
.insert(imvuProductInfo)
.values({ id: job.imvuProduct, found: false, checkedAt: now })
.onConflictDoUpdate({ target: imvuProductInfo.id, set: { found: false, checkedAt: now } });
} else {
const ok = checkSeen({ ...seen, id: job.imvuProduct });
if (!ok) throw new ProductError(400, "invalid", "That isn't a product's info.");
await this.keepSeen([ok], new Date());
[info] = await this.db.select().from(imvuProductInfo).where(eq(imvuProductInfo.id, job.imvuProduct));
}
return { rating: info?.rating ?? null, covered: !!info && covers(g, job.imvuProduct, info.creatorId) };
}
/** Queues signed-in listings of a catalog's whole-shop grants (once its importer has an Access Pass account). */
async queueListings(catalogId: string): Promise<number> {
const grants = await this.db
.select()
.from(importGrant)
.where(and(eq(importGrant.catalogId, catalogId), eq(importGrant.status, "active"), eq(importGrant.scope, "shop")));
let n = 0;
for (const g of grants) if (await this.queueListing(g)) n++;
return n;
}
/** A job of this catalog's that its importer has claimed. */
private async claimedJob(c: Catalog, jobId: string): Promise<Job> {
const [job] = await this.db.select().from(importJob).where(and(eq(importJob.id, jobId), eq(importJob.catalogId, c.id)));
if (!job) throw new ProductError(404, "not_found", "No such job.");
if (job.status !== "claimed") throw new ProductError(409, "not_claimed", "That job isn't claimed.");
return job;
} }
/** Lists the whole-shop grants not listed in a day, never-listed ones first. */ /** Lists the whole-shop grants not listed in a day, never-listed ones first. */
@@ -829,13 +951,17 @@ export class Imports {
.from(imvuProductInfo) .from(imvuProductInfo)
.where(and(inArray(imvuProductInfo.id, jobs.map((j) => j.imvuProduct)), eq(imvuProductInfo.found, true))) .where(and(inArray(imvuProductInfo.id, jobs.map((j) => j.imvuProduct)), eq(imvuProductInfo.found, true)))
: []; : [];
return jobs.map((j) => ({ return jobs.map((j) =>
j.kind === "list"
? { id: j.id, kind: j.kind, imvuProduct: 0, imvuCreator: j.imvuProduct, lastRevision: 0, rating: null }
: {
id: j.id, id: j.id,
kind: j.kind, kind: j.kind,
imvuProduct: j.imvuProduct, imvuProduct: j.imvuProduct,
lastRevision: last.find((l) => l.imvuProduct === j.imvuProduct)?.imvuRevision ?? 0, lastRevision: last.find((l) => l.imvuProduct === j.imvuProduct)?.imvuRevision ?? 0,
rating: infos.find((i) => i.id === j.imvuProduct)?.rating ?? null, rating: infos.find((i) => i.id === j.imvuProduct)?.rating ?? null,
})); },
);
} }
/** A claimed job of this catalog's, whose grant still covers its product. */ /** A claimed job of this catalog's, whose grant still covers its product. */
@@ -843,6 +969,7 @@ export class Imports {
const [job] = await this.db.select().from(importJob).where(and(eq(importJob.id, jobId), eq(importJob.catalogId, c.id))); const [job] = await this.db.select().from(importJob).where(and(eq(importJob.id, jobId), eq(importJob.catalogId, c.id)));
if (!job) throw new ProductError(404, "not_found", "No such job."); if (!job) throw new ProductError(404, "not_found", "No such job.");
if (job.status !== "claimed") throw new ProductError(409, "not_claimed", "That job isn't claimed."); if (job.status !== "claimed") throw new ProductError(409, "not_claimed", "That job isn't claimed.");
if (job.kind === "list") throw new ProductError(409, "not_product", "That job is a shop listing.");
const g = await this.grant(job.grantId); const g = await this.grant(job.grantId);
const info = await this.info(job.imvuProduct); const info = await this.info(job.imvuProduct);
if (!info || !covers(g, job.imvuProduct, info.creatorId)) throw new ProductError(409, "not_covered", "The grant no longer covers this product."); if (!info || !covers(g, job.imvuProduct, info.creatorId)) throw new ProductError(409, "not_covered", "The grant no longer covers this product.");
+84
View File
@@ -500,3 +500,87 @@ test("whole shops listed on IMVU, and what's available", async () => {
await call(owner, "POST", `/api/v1/imports/grants/${g2.json.grant.id}/accept`); await call(owner, "POST", `/api/v1/imports/grants/${g2.json.grant.id}/accept`);
expect((await call(owner, "POST", `/api/v1/imports/grants/${g2.json.grant.id}/list`)).json.error).toBe("not_shop"); expect((await call(owner, "POST", `/api/v1/imports/grants/${g2.json.grant.id}/list`)).json.error).toBe("not_shop");
}); });
test("Access Pass products, through the importer's signed-in account", async () => {
const owner = await person("apstall");
const keeper = await person("apkeeper", 903);
const chooser = await person("apchooser", 904);
const reg = await call(owner, "POST", "/api/v1/catalogs", { name: "AP Shelf", url: "https://ap.example.test", contact: "[email protected]", visibility: "public", membership: "open" });
const catalogID = reg.json.catalog.id as string;
const catalogAuth = { Authorization: `Catalog ${catalogID}:${reg.json.key}` };
expect((await call(rootAdmin, "POST", `/api/v1/console/catalogs/${catalogID}/approve`)).status).toBe(200);
const on = await call(owner, "POST", `/api/v1/catalogs/${catalogID}/importer`, { enabled: true });
const importer = { Authorization: `Importer ${catalogID}:${on.json.key}` };
const version = (await call(undefined, "GET", "/api/v1/imports/catalogs")).json.consent.version;
imvuProducts.set(9501, { ...imvuProduct("AP Keeper Coat", 903), creator_name: "apkeeperAv" });
shops.set("apkeeperav", [9501]); // what IMVU lists signed out: the general-rated one
for (const id of [9502, 9503, 9504, 9505]) hiddenProducts.add(id); // Access Pass (or gone): 401 to the hub
// Without an Access Pass account, the hub lists the shop itself; no signed-in listing.
const made = await call(keeper, "POST", "/api/v1/imports/grants", { catalog: catalogID, imvuId: 903, scope: "shop", consentVersion: version });
const grantID = made.json.grant.id as string;
await call(owner, "POST", `/api/v1/imports/grants/${grantID}/accept`);
await imports.listingsDone();
let claimed = (await call(undefined, "POST", "/api/v1/importer/jobs/claim", { limit: 10 }, importer)).json.jobs;
expect(claimed).toEqual([{ id: expect.any(String), kind: "import", imvuProduct: 9501, lastRevision: 0, rating: "general" }]);
await call(undefined, "POST", `/api/v1/importer/jobs/${claimed[0].id}`, { status: "failed", reason: "later" }, importer);
// The importer signs in with an account that has Access Pass: the catalog's whole shops are listed with it.
const [acct] = await db
.insert(schema.importerAccount)
.values({ id: "apacct0001", catalogId: catalogID, imvuId: 777, username: "ImporterAP", position: 0, state: "received" })
.returning();
const signedIn = await call(undefined, "POST", `/api/v1/importer/accounts/${acct!.id}`, { state: "ok", accessPass: true }, importer);
expect(signedIn.json.account).toMatchObject({ state: "ok", accessPass: true });
claimed = (await call(undefined, "POST", "/api/v1/importer/jobs/claim", { limit: 10 }, importer)).json.jobs;
expect(claimed).toEqual([{ id: expect.any(String), kind: "list", imvuProduct: 0, imvuCreator: 903, lastRevision: 0, rating: null }]);
const list = claimed[0].id as string;
expect((await call(undefined, "POST", `/api/v1/importer/jobs/${list}/token`, { imvuRevision: 1 }, importer)).json.error).toBe("not_product");
const seen = (id: number, name: string, rating: string, creatorId = 903) => ({ id, name, rating, creatorId, creatorName: "apkeeperAv", purchasable: true });
const listed = await call(
undefined,
"POST",
`/api/v1/importer/jobs/${list}/listing`,
{ products: [seen(9501, "AP Keeper Coat", "general"), seen(9502, "AP Keeper Robe", "adult"), seen(9503, "Someone Else's", "adult", 999)] },
importer,
);
expect(listed.json).toEqual({ listed: 2, queued: 1 }); // another creator's product isn't taken from it
expect(await imports.info(9502)).toMatchObject({ found: true, name: "AP Keeper Robe", rating: "adult", creatorId: 903 });
expect(await imports.info(9503)).toBeUndefined();
const grant = (await call(owner, "GET", `/api/v1/catalogs/${catalogID}/importer`)).json.grants[0];
expect(grant).toMatchObject({ shopListed: 2, shopListedSignedIn: true });
expect((await call(undefined, "POST", `/api/v1/importer/jobs/${list}/listing`, { products: [] }, importer)).json.error).toBe("not_claimed");
// The Access Pass product imports as adult; the hub's daily recheck keeps it though IMVU hides it from the hub.
claimed = (await call(undefined, "POST", "/api/v1/importer/jobs/claim", { limit: 10 }, importer)).json.jobs;
const robe = claimed.find((j: any) => j.imvuProduct === 9502);
expect(robe).toMatchObject({ kind: "import", rating: "adult" });
const tok = await call(undefined, "POST", `/api/v1/importer/jobs/${robe.id}/token`, { imvuRevision: 2 }, importer);
const r = await call(undefined, "POST", "/api/v1/catalog/revisions", { importToken: tok.json.token, files: [file("index.xml", 9502)], rating: "adult", parent: 0, name: "x" }, catalogAuth);
expect(r.status).toBe(201);
await db.update(schema.importJob).set({ updatedAt: new Date(Date.now() - 2 * 86_400_000) }).where(eq(schema.importJob.imvuProduct, 9502));
const rechecked = await imports.recheck();
expect(rechecked.withdrawn).not.toContain(r.json.product);
// Products chosen by ID that IMVU hides from the hub: the importer says what its account sees, then imports.
const g2 = await call(chooser, "POST", "/api/v1/imports/grants", { catalog: catalogID, imvuId: 904, scope: "products", products: [9504, 9505], consentVersion: version });
await call(owner, "POST", `/api/v1/imports/grants/${g2.json.grant.id}/accept`);
claimed = (await call(undefined, "POST", "/api/v1/importer/jobs/claim", { limit: 10 }, importer)).json.jobs;
const hidden = claimed.filter((j: any) => j.imvuProduct === 9504 || j.imvuProduct === 9505);
expect(hidden.map((j: any) => j.rating)).toEqual([null, null]);
const j4 = hidden.find((j: any) => j.imvuProduct === 9504);
const j5 = hidden.find((j: any) => j.imvuProduct === 9505);
expect((await call(undefined, "POST", `/api/v1/importer/jobs/${j4.id}/token`, { imvuRevision: 1 }, importer)).json.error).toBe("not_covered");
const info = await call(undefined, "POST", `/api/v1/importer/jobs/${j4.id}/info`, { found: true, name: "Chosen Veil", rating: "adult", creatorId: 904, creatorName: "chooserAv", purchasable: true }, importer);
expect(info.json).toEqual({ rating: "adult", covered: true });
expect((await call(undefined, "POST", `/api/v1/importer/jobs/${j4.id}/token`, { imvuRevision: 1 }, importer)).status).toBe(200);
// Another creator's, as the account sees it: not covered.
const other = await call(undefined, "POST", `/api/v1/importer/jobs/${j5.id}/info`, { found: true, name: "Not Theirs", rating: "general", creatorId: 999, creatorName: "x", purchasable: true }, importer);
expect(other.json).toEqual({ rating: "general", covered: false });
// What IMVU shows the hub publicly wins over the importer's word.
hiddenProducts.delete(9505);
imvuProducts.set(9505, { ...imvuProduct("Public Now", 904), creator_name: "chooserAv" });
const pub = await call(undefined, "POST", `/api/v1/importer/jobs/${j5.id}/info`, { found: false }, importer);
expect(pub.json).toEqual({ rating: "general", covered: true });
expect(await imports.info(9505)).toMatchObject({ name: "Public Now", creatorId: 904 });
});
@@ -157,7 +157,7 @@ export function ImporterAccountForm({
<p className="truncate font-medium">{found.username}</p> <p className="truncate font-medium">{found.username}</p>
<p className="text-xs text-muted-foreground">IMVU ID {found.imvuId}</p> <p className="text-xs text-muted-foreground">IMVU ID {found.imvuId}</p>
<div className="flex flex-wrap gap-1"> <div className="flex flex-wrap gap-1">
{found.accessPass ? <Tag tone="adult">Access Pass</Tag> : <Tag>No Access Pass</Tag>} {found.accessPass ? <Tag tone="adult">Access Pass</Tag> : <Tag>Access Pass not shown</Tag>}
{found.ageVerified ? <Tag tone="adult">Age verified</Tag> : <Tag>Not age verified</Tag>} {found.ageVerified ? <Tag tone="adult">Age verified</Tag> : <Tag>Not age verified</Tag>}
</div> </div>
</div> </div>
@@ -165,8 +165,8 @@ export function ImporterAccountForm({
)} )}
{found && !found.accessPass && ( {found && !found.accessPass && (
<p className="text-sm text-amber-700 dark:text-amber-400"> <p className="text-sm text-amber-700 dark:text-amber-400">
Without Access Pass, the importer can&apos;t see AP products, so it can&apos;t import them with this IMVU shows Access Pass publicly only if the member chooses to; the importer checks when it signs in.
account. Without Access Pass, it can&apos;t import Access Pass products with this account.
</p> </p>
)} )}
<p className="text-xs text-muted-foreground"> <p className="text-xs text-muted-foreground">
@@ -45,6 +45,7 @@ const accountState = {
needs_password: { tone: "danger", label: "needs its password" }, needs_password: { tone: "danger", label: "needs its password" },
} as const; } as const;
const imvuPage = (id: number) => `https://www.imvu.com/shop/product.php?products_id=${id}`; const imvuPage = (id: number) => `https://www.imvu.com/shop/product.php?products_id=${id}`;
const imvuShop = (creator: number) => `https://www.imvu.com/shop/web_search.php?manufacturers_id=${creator}`;
export default async function CatalogImports({ export default async function CatalogImports({
params, params,
@@ -178,7 +179,11 @@ export default async function CatalogImports({
<span className="font-medium">{a.username}</span> <span className="font-medium">{a.username}</span>
<span className="text-muted-foreground">(IMVU {a.imvuId})</span> <span className="text-muted-foreground">(IMVU {a.imvuId})</span>
<Tag tone={st.tone}>{st.label}</Tag> <Tag tone={st.tone}>{st.label}</Tag>
{a.accessPass ? <Tag tone="adult">Access Pass</Tag> : <Tag>No Access Pass</Tag>} {a.accessPass ? (
<Tag tone="adult">Access Pass</Tag>
) : (
<Tag>{a.state === "ok" ? "No Access Pass" : "Access Pass not checked"}</Tag>
)}
{a.stateMessage && <span className="text-xs text-muted-foreground">{a.stateMessage}</span>} {a.stateMessage && <span className="text-xs text-muted-foreground">{a.stateMessage}</span>}
</div> </div>
{can.run && ( {can.run && (
@@ -372,6 +377,16 @@ export default async function CatalogImports({
{data.jobs.map((j) => ( {data.jobs.map((j) => (
<TableRow key={j.id}> <TableRow key={j.id}>
<TableCell> <TableCell>
{j.kind === "list" ? (
<a
href={imvuShop(j.imvuProduct)}
target="_blank"
rel="noreferrer"
className="underline-offset-4 hover:underline"
>
IMVU shop {j.imvuProduct}
</a>
) : (
<a <a
href={imvuPage(j.imvuProduct)} href={imvuPage(j.imvuProduct)}
target="_blank" target="_blank"
@@ -380,9 +395,10 @@ export default async function CatalogImports({
> >
{j.name || j.imvuProduct} {j.name || j.imvuProduct}
</a> </a>
)}
</TableCell> </TableCell>
<TableCell className="text-muted-foreground"> <TableCell className="text-muted-foreground">
{j.kind} {j.kind === "list" ? "listing, signed in" : j.kind}
{j.imvuRevision ? ` · revision ${j.imvuRevision}` : ""} {j.imvuRevision ? ` · revision ${j.imvuRevision}` : ""}
</TableCell> </TableCell>
<TableCell className="whitespace-normal"> <TableCell className="whitespace-normal">
+10 -4
View File
@@ -4,16 +4,22 @@ import { DateTime } from "@/components/time";
export function ShopListing({ export function ShopListing({
grant: g, grant: g,
}: { }: {
grant: { scope: string; status: string; shopListedAt: string | null; shopListed: number }; grant: {
scope: string;
status: string;
shopListedAt: string | null;
shopListed: number;
shopListedSignedIn: boolean;
};
}) { }) {
if (g.scope !== "shop" || g.status !== "active") return null; if (g.scope !== "shop" || g.status !== "active") return null;
if (!g.shopListedAt) return <> Not checked on IMVU yet.</>; if (!g.shopListedAt) return <> Not checked on IMVU yet.</>;
return ( return (
<> <>
{" "} {" "}
On IMVU: {g.shopListed} general-rated product{g.shopListed === 1 ? "" : "s"} (checked{" "} On IMVU: {g.shopListed} {g.shopListedSignedIn ? "" : "general-rated "}product{g.shopListed === 1 ? "" : "s"}{" "}
<DateTime iso={g.shopListedAt} /> (checked <DateTime iso={g.shopListedAt} />
). {g.shopListedSignedIn ? " by the importer, with Access Pass" : ""}).
</> </>
); );
} }
+32 -4
View File
@@ -105,7 +105,7 @@ import_request(person, imvu_creator, imvu_product (0: the whole shop), created_a
## Import jobs ## Import jobs
``` ```
import_job(id, catalog, grant, imvu_product, kind ("import" | "recheck"), status ("queued" | "claimed" | "done" | "failed"), import_job(id, catalog, grant, imvu_product, kind ("import" | "recheck" | "list"), status ("queued" | "claimed" | "done" | "failed"),
imvu_revision, reason, attempts, claimed_at, next_at, created_at, updated_at) imvu_revision, reason, attempts, claimed_at, next_at, created_at, updated_at)
``` ```
@@ -188,9 +188,35 @@ passwords never reach the hub readable, and are kept only by the importer.
(`catalog.importer_hello`). (`catalog.importer_hello`).
- Built (2026-11-07): all of the above on the hub and the console, except the importer's report of AP products' info - Built (2026-11-07): all of the above on the hub and the console, except the importer's report of AP products' info
(with the importer). (with the importer).
- What the importer sees with an account (creator, name, rating of AP products) it reports to the hub with the job - What the importer sees with an account it reports to the hub ("Access Pass products" below), trusted from that
(`POST /api/v1/importer/jobs/:id {product: {creatorId, name, rating}}`), trusted from that catalog's importer catalog's importer only, for products IMVU hides from the hub.
only, for products IMVU hides from the hub. - IMVU shows an account's Access Pass publicly only if its member chooses to (verified 2026-11-08: an AP account's
public profile said `is_ap: false`, its own signed-in view `true`). So the console's lookup shows "Access Pass not
shown", and the importer reports the real answer when it signs in (`accessPass` with state `ok`).
### Access Pass products
Signed out, IMVU hides Access Pass products: the product API answers 401 (as for deleted products and made-up IDs)
and shop listings leave them out (2026-11-08: NellLuna's shop lists 639 products signed out, 763 signed in with
Access Pass; `product_rating=AP` lists the 124 others). The CDN serves their files to anyone. So the hub learns
about them from the importer's account:
- **Signed-in shop listings**: when a whole-shop grant's shop is listed (accepted, daily, "List the shop again"), and
the catalog's importer has an account that signed in with Access Pass (state `ok`, `accessPass`), the hub also
queues a `list` job (one open per shop and catalog; also queued for every whole shop when such an account first
reports in). The importer lists the shop signed in and reports every product it saw (`POST
/api/v1/importer/jobs/:id/listing`); the hub keeps those of the grant's IMVU account (an importer can't vouch for
another creator's products), records the count (`shopListedSignedIn`: "with Access Pass"), and queues those not
imported yet. The job is then done.
- **Single products** (a grant's chosen products, or a request the hub couldn't place): a claimed job whose
`rating` is null is one IMVU hides from the hub. The importer looks it up signed in and reports what it saw (`POST
/api/v1/importer/jobs/:id/info`); the hub keeps it (unless IMVU now shows the product publicly: that wins), and
answers `{rating, covered}`. Not covered (another creator's): the importer fails the job with that reason.
`found: false` (gone for the account too) is kept, so the daily recheck withdraws an imported product.
- **Rechecks** keep what was last seen for a product IMVU hides (401), so imported Access Pass products aren't
withdrawn for being hidden. Not built: noticing that a hidden product was deleted, except when a job's lookup says
so.
- Built (2026-11-08) on the hub; the importer's side is t5de-importer's.
## Hub routes ## Hub routes
@@ -204,6 +230,8 @@ passwords never reach the hub readable, and are kept only by the importer.
| `DELETE /api/v1/imports/grants/:id` | (its creator, or `import:withdraw` at the catalog) `{reason?}` → `{grant, withdrawn}` | | `DELETE /api/v1/imports/grants/:id` | (its creator, or `import:withdraw` at the catalog) `{reason?}` → `{grant, withdrawn}` |
| `POST /api/v1/imports/grants/:id/list` | (its creator, or `import:run` at the catalog) → `{grant, listed, queued}`: an active whole-shop grant's shop listed on IMVU now. 409 `not_shop`; 429 after 3 an hour. | | `POST /api/v1/imports/grants/:id/list` | (its creator, or `import:run` at the catalog) → `{grant, listed, queued}`: an active whole-shop grant's shop listed on IMVU now. 409 `not_shop`; 429 after 3 an hour. |
| `GET /api/v1/imports/available?products=&creators=` | (anyone) up to 100 IMVU product IDs and 100 IMVU account IDs, comma-separated → `{products: [{imvuProduct, status, product, requested?}], shops: [{imvuCreator, shop, products}]}`. `status`: `imported` (`product` is the hub product), `adult` (imported, but the person can't see adult products), `queued`, `covered` (a grant covers it: asking queues it) or `none` (asking counts it). `requested` (signed in): they asked for it. `shop`: an active whole-shop grant; `products`: how many of the shop's are on T5DE. From what the hub knows only (it asks IMVU nothing), for the proxy's "Get on T5DE". | | `GET /api/v1/imports/available?products=&creators=` | (anyone) up to 100 IMVU product IDs and 100 IMVU account IDs, comma-separated → `{products: [{imvuProduct, status, product, requested?}], shops: [{imvuCreator, shop, products}]}`. `status`: `imported` (`product` is the hub product), `adult` (imported, but the person can't see adult products), `queued`, `covered` (a grant covers it: asking queues it) or `none` (asking counts it). `requested` (signed in): they asked for it. `shop`: an active whole-shop grant; `products`: how many of the shop's are on T5DE. From what the hub knows only (it asks IMVU nothing), for the proxy's "Get on T5DE". |
| `POST /api/v1/importer/jobs/:id/listing` | (the catalog's importer) a claimed `list` job: `{products: [{id, name, rating, creatorId, creatorName, purchasable}]}` (up to 10,000) → `{listed, queued}`: the grant's IMVU account's products are kept and queued; the job is done ("Access Pass products") |
| `POST /api/v1/importer/jobs/:id/info` | (the catalog's importer) a claimed import or recheck job: `{found, name?, rating?, creatorId?, creatorName?, purchasable?}`, as its IMVU account sees the product → `{rating, covered}` |
| `POST /api/v1/imports/requests` | `{imvuProduct}` or `{imvuCreator}` → `{status: "added" \| "queued" \| "suggested" \| "counted", product?}` (`added`: imported already, now in their library). At most 50 a day. | | `POST /api/v1/imports/requests` | `{imvuProduct}` or `{imvuCreator}` → `{status: "added" \| "queued" \| "suggested" \| "counted", product?}` (`added`: imported already, now in their library). At most 50 a day. |
| `GET /api/v1/imports/requests?imvuCreator=` | `{requests: [{imvuProduct (0: the whole shop), name, requests}]}` for a linked account of theirs (moderators: any); without `imvuCreator`, moderators get `{creators}`: the most asked-for IMVU creators | | `GET /api/v1/imports/requests?imvuCreator=` | `{requests: [{imvuProduct (0: the whole shop), name, requests}]}` for a linked account of theirs (moderators: any); without `imvuCreator`, moderators get `{creators}`: the most asked-for IMVU creators |
| `GET /api/v1/catalogs/:id/importer` | (`import:accept` or `import:pause`) `{importer, grants, jobs, counts, permissions}`; `?status=` filters jobs | | `GET /api/v1/catalogs/:id/importer` | (`import:accept` or `import:pause`) `{importer, grants, jobs, counts, permissions}`; `?status=` filters jobs |
+4 -2
View File
@@ -82,8 +82,10 @@ catalog's). Only approved catalogs with imports on and not paused.
| | | | | |
| --- | --- | | --- | --- |
| `POST /api/v1/importer/jobs/claim` | `{limit}` (1-20) → `{jobs: [{id, kind, imvuProduct, lastRevision, rating}]}`; `rating` is IMVU's (`general`, `adult`, or null when the hub couldn't see it), for the importer to write into `index.xml` as `ProductRating` (GA, AP); claimed jobs not reported within 30 minutes go back to the queue | | `POST /api/v1/importer/jobs/claim` | `{limit}` (1-20) → `{jobs: [{id, kind, imvuProduct, lastRevision, rating}]}`; `kind` is `import`, `recheck` or `list`; `rating` is IMVU's (`general`, `adult`, or null when IMVU hides the product from the hub: the importer reports what its account sees first, `/info` below), for the importer to write into `index.xml` as `ProductRating` (GA, AP). A `list` job (a whole shop, signed in) has `imvuCreator` (the shop's IMVU account) and `imvuProduct` 0. Claimed jobs not reported within 30 minutes go back to the queue |
| `POST /api/v1/importer/jobs/:id/token` | `{imvuRevision}` → `{token, url}`: a `t5de-import` token and the catalog's upload URL | | `POST /api/v1/importer/jobs/:id/token` | `{imvuRevision}` → `{token, url}`: a `t5de-import` token and the catalog's upload URL (not for `list` jobs: 409 `not_product`) |
| `POST /api/v1/importer/jobs/:id/listing` | a `list` job's products, as the importer's IMVU account lists the shop: `{products: [{id, name, rating, creatorId, creatorName, purchasable}]}` → `{listed, queued}` (imports.md, "Access Pass products") |
| `POST /api/v1/importer/jobs/:id/info` | an import or recheck job's product, as the importer's IMVU account sees it: `{found, name?, rating?, creatorId?, creatorName?, purchasable?}` → `{rating, covered}` |
| `POST /api/v1/importer/jobs/:id` | `{status: "done" \| "failed" \| "unchanged", imvuRevision?, reason?}` | | `POST /api/v1/importer/jobs/:id` | `{status: "done" \| "failed" \| "unchanged", imvuRevision?, reason?}` |
| `POST /api/v1/importer/hello` | `{version, publicKey}` (base64 SPKI, RSA 3072 to 4096 bits) → the config, as below. Sent at start. A new key means passwords sealed for the old one can't be read: the catalog's accounts then need their passwords again (imports.md "IMVU accounts"). | | `POST /api/v1/importer/hello` | `{version, publicKey}` (base64 SPKI, RSA 3072 to 4096 bits) → the config, as below. Sent at start. A new key means passwords sealed for the old one can't be read: the catalog's accounts then need their passwords again (imports.md "IMVU accounts"). |
| `GET /api/v1/importer/config` | `{paused, settings: {rate, concurrency}, fingerprint, accounts: [{id, imvuId, username, sealed}]}`, accounts in the order to try them. `sealed` (or null): `{imvuId, password}` as JSON, RSA-OAEP (SHA-256) for the importer's key, base64; check `imvuId`. Polled every minute; accounts no longer listed are forgotten. | | `GET /api/v1/importer/config` | `{paused, settings: {rate, concurrency}, fingerprint, accounts: [{id, imvuId, username, sealed}]}`, accounts in the order to try them. `sealed` (or null): `{imvuId, password}` as JSON, RSA-OAEP (SHA-256) for the importer's key, base64; check `imvuId`. Polled every minute; accounts no longer listed are forgotten. |
@@ -0,0 +1,4 @@
DROP INDEX "import_job_open";--> statement-breakpoint
ALTER TABLE "import_grant" ADD COLUMN "shop_listed_signed_in" boolean DEFAULT false NOT NULL;--> statement-breakpoint
CREATE UNIQUE INDEX "import_job_list_open" ON "import_job" USING btree ("catalog_id","imvu_product") WHERE "import_job"."status" in ('queued', 'claimed') and "import_job"."kind" = 'list';--> statement-breakpoint
CREATE UNIQUE INDEX "import_job_open" ON "import_job" USING btree ("catalog_id","imvu_product") WHERE "import_job"."status" in ('queued', 'claimed') and "import_job"."kind" <> 'list';
File diff suppressed because it is too large. Load diff
+7
View File
@@ -141,6 +141,13 @@
"when": 1794092472616, "when": 1794092472616,
"tag": "0019_shop_listing", "tag": "0019_shop_listing",
"breakpoints": true "breakpoints": true
},
{
"idx": 20,
"version": "7",
"when": 1794150630963,
"tag": "0020_importer_signed_in",
"breakpoints": true
} }
] ]
} }
+7 -3
View File
@@ -757,6 +757,7 @@ export const importGrant = pgTable(
// IMVU lists no Access Pass products to the signed out). // IMVU lists no Access Pass products to the signed out).
shopListedAt: timestamp("shop_listed_at", { withTimezone: true }), shopListedAt: timestamp("shop_listed_at", { withTimezone: true }),
shopListed: integer("shop_listed").notNull().default(0), shopListed: integer("shop_listed").notNull().default(0),
shopListedSignedIn: boolean("shop_listed_signed_in").notNull().default(false), // by the importer, signed in: AP products too
// "pending" (the catalog's team hasn't accepted), "active", "declined", "suspended", "withdrawn". // "pending" (the catalog's team hasn't accepted), "active", "declined", "suspended", "withdrawn".
status: text("status").notNull().default("pending"), status: text("status").notNull().default("pending"),
statusReason: text("status_reason").notNull().default(""), statusReason: text("status_reason").notNull().default(""),
@@ -799,7 +800,7 @@ export const importJob = pgTable(
.notNull() .notNull()
.references(() => importGrant.id, { onDelete: "cascade" }), .references(() => importGrant.id, { onDelete: "cascade" }),
imvuProduct: bigint("imvu_product", { mode: "number" }).notNull(), imvuProduct: bigint("imvu_product", { mode: "number" }).notNull(),
kind: text("kind").notNull(), // "import", "recheck" kind: text("kind").notNull(), // "import", "recheck", "list" (a whole shop, signed in: imvuProduct is the creator's IMVU ID)
status: text("status").notNull().default("queued"), // "queued", "claimed", "done", "failed" status: text("status").notNull().default("queued"), // "queued", "claimed", "done", "failed"
imvuRevision: integer("imvu_revision"), // done: the revision imported (or found unchanged) imvuRevision: integer("imvu_revision"), // done: the revision imported (or found unchanged)
reason: text("reason").notNull().default(""), // why it failed (last attempt) reason: text("reason").notNull().default(""), // why it failed (last attempt)
@@ -811,10 +812,13 @@ export const importJob = pgTable(
}, },
(t) => [ (t) => [
index("import_job_queue").on(t.catalogId, t.status, t.nextAt), index("import_job_queue").on(t.catalogId, t.status, t.nextAt),
// One open job per product and catalog. // One open job per product and catalog, and one open listing per shop and catalog.
uniqueIndex("import_job_open") uniqueIndex("import_job_open")
.on(t.catalogId, t.imvuProduct) .on(t.catalogId, t.imvuProduct)
.where(sql`${t.status} in ('queued', 'claimed')`), .where(sql`${t.status} in ('queued', 'claimed') and ${t.kind} <> 'list'`),
uniqueIndex("import_job_list_open")
.on(t.catalogId, t.imvuProduct)
.where(sql`${t.status} in ('queued', 'claimed') and ${t.kind} = 'list'`),
], ],
); );