a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

support rkeys in pub urls

+25 -5
+11 -2
app/api/rpc/[command]/get_publication_data.ts
··· 1 1 import { z } from "zod"; 2 2 import { makeRoute } from "../lib"; 3 3 import type { Env } from "./route"; 4 + import { AtUri } from "@atproto/syntax"; 4 5 5 6 export type GetPublicationDataReturnType = Awaited< 6 7 ReturnType<(typeof get_publication_data)["handler"]> ··· 15 16 { did, publication_name }, 16 17 { supabase }: Pick<Env, "supabase">, 17 18 ) => { 18 - let { data: publication } = await supabase 19 + let uri; 20 + if (/^(?!\.$|\.\.S)[A-Za-z0-9._:~-]{1,512}$/.test(publication_name)) { 21 + uri = AtUri.make( 22 + did, 23 + "pub.leaflet.publication", 24 + publication_name, 25 + ).toString(); 26 + } 27 + let { data: publication, error } = await supabase 19 28 .from("publications") 20 29 .select( 21 30 `*, ··· 29 38 ) 30 39 )`, 31 40 ) 41 + .or(`name.eq."${publication_name}", uri.eq."${uri}"`) 32 42 .eq("identity_did", did) 33 - .eq("name", publication_name) 34 43 .single(); 35 44 36 45 return { result: publication };
+3 -1
app/lish/[did]/[publication]/dashboard/page.tsx
··· 34 34 }, 35 35 { supabase: supabaseServerClient }, 36 36 ); 37 + let record = 38 + (publication?.record as PubLeafletPublication.Record) || undefined; 37 39 if (!publication) return { title: "404 Publication" }; 38 - return { title: decodeURIComponent((await props.params).publication) }; 40 + return { title: record?.name || "Untitled Publication" }; 39 41 } 40 42 41 43 //This is the admin dashboard of the publication
+11 -2
app/lish/[did]/[publication]/page.tsx
··· 37 37 38 38 let record = publication.record as PubLeafletPublication.Record | null; 39 39 return { 40 - title: decodeURIComponent(params.publication), 40 + title: record?.name || "Untitled Publication", 41 41 description: record?.description || "", 42 42 }; 43 43 } ··· 49 49 let did = decodeURIComponent(params.did); 50 50 if (!did) return <PubNotFound />; 51 51 let agent = new BskyAgent({ service: "https://public.api.bsky.app" }); 52 + let uri; 53 + let publication_name = decodeURIComponent(params.publication); 54 + if (/^(?!\.$|\.\.S)[A-Za-z0-9._:~-]{1,512}$/.test(publication_name)) { 55 + uri = AtUri.make( 56 + did, 57 + "pub.leaflet.publication", 58 + publication_name, 59 + ).toString(); 60 + } 52 61 let [{ data: publication }, { data: profile }] = await Promise.all([ 53 62 supabaseServerClient 54 63 .from("publications") ··· 59 68 `, 60 69 ) 61 70 .eq("identity_did", did) 62 - .eq("name", decodeURIComponent(params.publication)) 71 + .or(`name.eq."${publication_name}", uri.eq."${uri}"`) 63 72 .single(), 64 73 agent.getProfile({ actor: did }), 65 74 ]);