From ccfd9aa58a72fe3c687080141573a0443023c67e Mon Sep 17 00:00:00 2001 From: dawn Date: Thu, 8 Oct 2026 01:16:27 +0300 Subject: [PATCH] web: write issue and pull subscriptions with the record subject createEntitySubscription wrote the subject as org.tangled.feed.subscription#uri, which the lexicon doesn't have (only #record and #repo), so bobbin rejected every issue and pull subscription as undecodable. getForActor then always answered 404, the subscribe button never knew you were subscribed, and each comment added another record. Signed-off-by: dawn --- web/src/lib/api/graph.test.ts | 24 +++++++++++++++++++++++- web/src/lib/api/graph.ts | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/web/src/lib/api/graph.test.ts b/web/src/lib/api/graph.test.ts index 25449f320..7cba9bc67 100644 --- a/web/src/lib/api/graph.test.ts +++ b/web/src/lib/api/graph.test.ts @@ -1,6 +1,19 @@ +import { is } from "@atcute/lexicons/validations"; +import type { OAuthUserAgent } from "@atcute/oauth-browser-client"; import { describe, expect, it, vi } from "vitest"; import { createBobbinClient } from "$lib/api/client"; -import { listNetworkVouches } from "$lib/api/graph"; +import { createEntitySubscription, listNetworkVouches } from "$lib/api/graph"; +import { mainSchema as subscriptionSchema } from "$lib/api/lexicons/types/org/tangled/feed/subscription"; +import { createRecord } from "$lib/api/write"; + +vi.mock("$lib/api/write", () => ({ + createRecord: vi.fn(async () => ({ + uri: "at://did:plc:alice/org.tangled.feed.subscription/3l7abc", + cid: "bafytest" + })), + deleteRecord: vi.fn(), + putRecord: vi.fn() +})); const response = (items: unknown[] = []) => new Response(JSON.stringify({ items }), { @@ -44,3 +57,12 @@ describe("network vouches", () => { expect(result.items[bob]).toHaveLength(2); }); }); + +describe("entity subscriptions", () => { + it("writes a record the subscription lexicon accepts", async () => { + const agent = { sub: "did:plc:alice" } as unknown as OAuthUserAgent; + await createEntitySubscription(agent, "at://did:plc:bob/org.tangled.track.ticket/3l7xyz"); + const [, , record] = vi.mocked(createRecord).mock.calls[0]; + expect(is(subscriptionSchema, record)).toBe(true); + }); +}); diff --git a/web/src/lib/api/graph.ts b/web/src/lib/api/graph.ts index 1b1f8c16c..8d4502a6c 100644 --- a/web/src/lib/api/graph.ts +++ b/web/src/lib/api/graph.ts @@ -149,7 +149,7 @@ export const createEntitySubscription = async ( const { uri } = await createRecord(agent, SUBSCRIPTION_COLLECTION, { $type: SUBSCRIPTION_COLLECTION, subject: { - $type: "org.tangled.feed.subscription#uri", + $type: "org.tangled.feed.subscription#record", uri: entityUri }, createdAt: new Date().toISOString() -- 2.51.2