feat: render some real content
This commit is contained in:
@@ -1,5 +1,22 @@
|
||||
const correspondanceCache = new Map<string, string>()
|
||||
|
||||
export const getUniqueAka = async (did: string) => {
|
||||
if (correspondanceCache.has(did)) {
|
||||
return correspondanceCache.get(did) as string
|
||||
}
|
||||
|
||||
const response = await fetch(`https://plc.directory/${did}`)
|
||||
const {
|
||||
alsoKnownAs: [aka],
|
||||
} = await response.json()
|
||||
|
||||
const alias = aka.replace("at://", "")
|
||||
|
||||
correspondanceCache.set(did, alias)
|
||||
|
||||
return alias
|
||||
}
|
||||
|
||||
export const getAka = async (dids: Set<string>) => {
|
||||
const correspondance = await Promise.all(
|
||||
[...dids].map(async (did) => {
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
export const getUrl = async ({ did, rkey }: { did: string; rkey: string }) => {
|
||||
const endpointCache = new Map<string, string>()
|
||||
|
||||
const getEndpoint = async (did: string) => {
|
||||
if (endpointCache.has(did)) {
|
||||
return endpointCache.get(did)
|
||||
}
|
||||
const response = await fetch(`https://plc.directory/${did}`)
|
||||
const {
|
||||
service: [{ serviceEndpoint }],
|
||||
} = await response.json()
|
||||
|
||||
const url = new URL("/xrpc/com.atproto.repo.getRecord", serviceEndpoint)
|
||||
endpointCache.set(did, serviceEndpoint)
|
||||
|
||||
return serviceEndpoint as string
|
||||
}
|
||||
|
||||
export const getUrl = async ({ did, rkey }: { did: string; rkey: string }) => {
|
||||
const url = new URL(
|
||||
"/xrpc/com.atproto.repo.getRecord",
|
||||
await getEndpoint(did),
|
||||
)
|
||||
url.searchParams.set("repo", did)
|
||||
url.searchParams.set("collection", "space.litenote.note")
|
||||
url.searchParams.set("rkey", rkey)
|
||||
|
||||
Reference in New Issue
Block a user