From 56f9e29573a37448b163749591f2e19774c6326f Mon Sep 17 00:00:00 2001 From: dhkatz Date: Sun, 8 Nov 2026 05:52:43 -0800 Subject: [PATCH] feat(imports): job claims carry IMVU's rating The importer writes it into index.xml as ProductRating, so the files agree with the revision's rating. Co-Authored-By: Claude Opus 5.5 --- apps/api/src/imports.ts | 9 +++++++++ apps/api/test/imports.test.ts | 2 +- docs/imports.md | 5 +++-- docs/products.md | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/api/src/imports.ts b/apps/api/src/imports.ts index cbf09ee..d70a439 100644 --- a/apps/api/src/imports.ts +++ b/apps/api/src/imports.ts @@ -821,11 +821,20 @@ export class Imports { .where(inArray(product.imvuProduct, jobs.map((j) => j.imvuProduct))) .groupBy(product.imvuProduct) : []; + // IMVU's rating, as the hub knows it: the importer writes it into index.xml (IMVU's files have no ProductRating), + // so the files agree with the revision's rating (the higher of the two). + const infos = jobs.length + ? await this.db + .select({ id: imvuProductInfo.id, rating: imvuProductInfo.rating }) + .from(imvuProductInfo) + .where(and(inArray(imvuProductInfo.id, jobs.map((j) => j.imvuProduct)), eq(imvuProductInfo.found, true))) + : []; return jobs.map((j) => ({ id: j.id, kind: j.kind, imvuProduct: j.imvuProduct, lastRevision: last.find((l) => l.imvuProduct === j.imvuProduct)?.imvuRevision ?? 0, + rating: infos.find((i) => i.id === j.imvuProduct)?.rating ?? null, })); } diff --git a/apps/api/test/imports.test.ts b/apps/api/test/imports.test.ts index 91e40b6..fea7a69 100644 --- a/apps/api/test/imports.test.ts +++ b/apps/api/test/imports.test.ts @@ -166,7 +166,7 @@ test("grants, requests, the importer's jobs, and withdrawal", async () => { // The importer claims the job, gets a token for the revision it found, and uploads; the catalog registers it. const claimed = (await call(undefined, "POST", "/api/v1/importer/jobs/claim", { limit: 5 }, importer)).json.jobs; - expect(claimed).toEqual([{ id: expect.any(String), kind: "import", imvuProduct: 9001, lastRevision: 0 }]); + expect(claimed).toEqual([{ id: expect.any(String), kind: "import", imvuProduct: 9001, lastRevision: 0, rating: "general" }]); const tok = await call(undefined, "POST", `/api/v1/importer/jobs/${claimed[0].id}/token`, { imvuRevision: 3 }, importer); expect(tok.json.url).toBe("https://imports.example.test/api/v1/uploads"); const files = [file("index.xml", 11), file("dress.xmf", 12)]; diff --git a/docs/imports.md b/docs/imports.md index a91a8b7..6d9c5f2 100644 --- a/docs/imports.md +++ b/docs/imports.md @@ -157,8 +157,9 @@ pair and the IMVU accounts' passwords. - Reads CFLs with t5de-api's `cfl` package; the conversion follows `@imvu/chkn` (dhkatz/imvu.js) as a reference. IMVU's CFLs are LZMA-compressed (directory and entries), which `cfl` doesn't read yet: it needs LZMA (pylzma's format; the streams end with an end marker). -- Adds `` to `index.xml` (IMVU's files don't have it; pack rules need it): IMVU's rating, or the - files' if they have a higher one. +- Adds `` to `index.xml` (IMVU's files don't have it; pack rules need it): IMVU's rating, which the + job claim carries, or AP if the files have it. The hub rates the revision the higher of IMVU's and the files', and + the proxy needs the files to agree. - Validates with t5de-api's `pack` rules before uploading; a product breaking them fails with the reason. (In the spike, products were far inside them.) diff --git a/docs/products.md b/docs/products.md index f0edbf3..138e76a 100644 --- a/docs/products.md +++ b/docs/products.md @@ -82,7 +82,7 @@ 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}]}`; 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}]}`; `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/:id/token` | `{imvuRevision}` → `{token, url}`: a `t5de-import` token and the catalog's upload URL | | `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"). |