feat(imports): Access Pass products through the importer's signed-in account
IMVU hides Access Pass products from the signed out, so the hub learns about them from the importer: a "list" job has it list a whole shop signed in (queued with each listing once its importer has an account that signed in with Access Pass), and a job's product the hub can't see is looked up by the importer first (/info). The console no longer says an account has no Access Pass when IMVU merely doesn't show it publicly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
56d25f7507
commit
e2308aa0aa
12 files changed
+4865
-51
No files matched your search
@@ -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`);
|
||||
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 });
|
||||
});
|
||||
Reference in new issue
Block a user