···5555 authorDid = did;
5656 } else {
5757 // Publication post: look up by custom domain
5858+ // Support both old format (pub.leaflet.publication with base_path) and
5959+ // new format (site.standard.publication with url as https://domain)
5860 let { data: pub, error } = await supabaseServerClient
5961 .from("publications")
6062 .select("*")
6161- .eq("record->>base_path", url.host)
6363+ .or(`record->>base_path.eq.${url.host},record->>url.eq.https://${url.host}`)
6264 .single();
63656466 if (!pub) {
···4848 let agent = new AtpBaseClient(
4949 credentialSession.fetchHandler.bind(credentialSession),
5050 );
5151- let record = await agent.pub.leaflet.graph.subscription.create(
5151+ let record = await agent.site.standard.graph.subscription.create(
5252 { repo: credentialSession.did!, rkey: TID.nextStr() },
5353 {
5454 publication,
···140140 .eq("publication", publication)
141141 .single();
142142 if (!existingSubscription) return { success: true };
143143- await agent.pub.leaflet.graph.subscription.delete({
144144- repo: credentialSession.did!,
145145- rkey: new AtUri(existingSubscription.uri).rkey,
146146- });
143143+144144+ // Delete from both collections (old and new schema) - one or both may exist
145145+ let rkey = new AtUri(existingSubscription.uri).rkey;
146146+ await Promise.all([
147147+ agent.pub.leaflet.graph.subscription.delete({ repo: credentialSession.did!, rkey }).catch(() => {}),
148148+ agent.site.standard.graph.subscription.delete({ repo: credentialSession.did!, rkey }).catch(() => {}),
149149+ ]);
150150+147151 await supabaseServerClient
148152 .from("publication_subscriptions")
149153 .delete()
+4-1
appview/index.ts
···247247 if (docResult.error) console.log(docResult.error);
248248249249 // site.standard.document uses "site" field to reference the publication
250250- if (record.value.site) {
250250+ // For documents in publications, site is an AT-URI (at://did:plc:xxx/site.standard.publication/rkey)
251251+ // For standalone documents, site is an HTTPS URL (https://leaflet.pub/p/did:plc:xxx)
252252+ // Only link to publications table for AT-URI sites
253253+ if (record.value.site && record.value.site.startsWith("at://")) {
251254 let siteURI = new AtUri(record.value.site);
252255253256 if (siteURI.host !== evt.uri.host) {