diff options
author | Mary <148872143+mary-ext@users.noreply.github.com> | 2024-01-24 06:11:07 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 15:11:07 -0800 |
commit | 6076b8f73056a7cc04904bd0aa4571b17fd4978d (patch) | |
tree | af59920c441a4dc7613f7d5d215cbc3d001f7ef1 /src/lib/link-meta | |
parent | 439f459cefbbbf4dec386d8e9eea1db06484dab3 (diff) | |
download | voidsky-6076b8f73056a7cc04904bd0aa4571b17fd4978d.tar.zst |
fix: resolve handle in feed/list urls (#2497)
Diffstat (limited to 'src/lib/link-meta')
-rw-r--r-- | src/lib/link-meta/bsky.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/link-meta/bsky.ts b/src/lib/link-meta/bsky.ts index 322b02332..c1fbb34b3 100644 --- a/src/lib/link-meta/bsky.ts +++ b/src/lib/link-meta/bsky.ts @@ -5,6 +5,7 @@ import {LikelyType, LinkMeta} from './link-meta' import {convertBskyAppUrlIfNeeded, makeRecordUri} from '../strings/url-helpers' import {ComposerOptsQuote} from 'state/shell/composer' import {useGetPost} from '#/state/queries/post' +import {useFetchDid} from '#/state/queries/handle' // TODO // import {Home} from 'view/screens/Home' @@ -120,11 +121,13 @@ export async function getPostAsQuote( export async function getFeedAsEmbed( agent: BskyAgent, + fetchDid: ReturnType<typeof useFetchDid>, url: string, ): Promise<apilib.ExternalEmbedDraft> { url = convertBskyAppUrlIfNeeded(url) - const [_0, user, _1, rkey] = url.split('/').filter(Boolean) - const feed = makeRecordUri(user, 'app.bsky.feed.generator', rkey) + const [_0, handleOrDid, _1, rkey] = url.split('/').filter(Boolean) + const did = await fetchDid(handleOrDid) + const feed = makeRecordUri(did, 'app.bsky.feed.generator', rkey) const res = await agent.app.bsky.feed.getFeedGenerator({feed}) return { isLoading: false, @@ -146,11 +149,13 @@ export async function getFeedAsEmbed( export async function getListAsEmbed( agent: BskyAgent, + fetchDid: ReturnType<typeof useFetchDid>, url: string, ): Promise<apilib.ExternalEmbedDraft> { url = convertBskyAppUrlIfNeeded(url) - const [_0, user, _1, rkey] = url.split('/').filter(Boolean) - const list = makeRecordUri(user, 'app.bsky.graph.list', rkey) + const [_0, handleOrDid, _1, rkey] = url.split('/').filter(Boolean) + const did = await fetchDid(handleOrDid) + const list = makeRecordUri(did, 'app.bsky.graph.list', rkey) const res = await agent.app.bsky.graph.getList({list}) return { isLoading: false, |