vod site for atmosphere conf 2026 conf-vods.wisp.place/
bluesky atmosphere conference atproto
at main 65 lines 2.0 kB view raw
1import { xrpcSafe } from "@atproto/lex"; 2import { getMiniDoc } from "./microcosm" 3import * as com from "#/__generated__/com" 4import * as tv from "#/__generated__/tv" 5 6const IONOSPHERE_REPO_DID = "did:plc:lkeq4oghyhnztbu4dxr3joff"; 7 8export type Talks = Awaited<ReturnType<typeof getTalks>> 9export type Talk = Talks[number] 10 11export async function getTalks() { 12 const pds = await getMiniDoc(IONOSPHERE_REPO_DID); 13 if (!pds) throw new Error("Failed to get PDS for events repo") 14 15 const talks = await xrpcSafe(pds, com.atproto.repo.listRecords, { 16 params: { 17 collection: "tv.ionosphere.talk", 18 repo: IONOSPHERE_REPO_DID, 19 limit: 100 20 } 21 }) 22 23 if (!talks.success) { 24 throw new Error("Failed to fetch talks") 25 } 26 27 const validatedTalks = talks.body.records.map(record => tv.ionosphere.talk.$safeParse(record.value)).filter(result => result.success).map(result => result.value) 28 29 const talksWithResolvedSpeakers = await Promise.all(validatedTalks.map(async talk => { 30 if (!talk.speakerUris?.length) { 31 return { 32 ...talk, 33 roomId: labelToId(talk.room), 34 categoryId: labelToId(talk.category), 35 speakers: [] 36 } 37 } 38 const speakers = await Promise.all(talk.speakerUris.map(async speakerUri => { 39 const rkey = speakerUri.split("/").pop()! 40 const result = await xrpcSafe(pds, com.atproto.repo.getRecord, { 41 params: { 42 collection: "tv.ionosphere.speaker", 43 repo: IONOSPHERE_REPO_DID, 44 rkey, 45 }, 46 }) 47 if (!result.success) return null 48 const speaker = tv.ionosphere.speaker.$safeParse(result.body.value) 49 return speaker.success ? speaker.value : null 50 })) 51 return { 52 ...talk, 53 roomId: labelToId(talk.room), 54 categoryId: labelToId(talk.category), 55 speakers: speakers.filter((s): s is NonNullable<typeof s> => s !== null), 56 } 57 }) 58 ) 59 60 return talksWithResolvedSpeakers 61} 62 63function labelToId(label?: string) { 64 return label?.toLowerCase().split(" ").join("-") 65}