Created
December 15, 2024 12:44
-
-
Save YonatanKra/1b1261e854a608efeb4fe67f5bd1b1b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function parsePostUri(uri: string, agent: AtpAgent): Promise<{ repo: string; collection: string; rkey: string; } | boolean> { | |
// Extract handle and post ID | |
const match = uri.match(/profile\/([^/]+)\/post\/([^/]+)/); | |
if (!match) { | |
return false; | |
} | |
const [, handle, rkey] = match; | |
// Get the did | |
const { data: { did: repo }} = await agent.resolveHandle({handle}); | |
// Use the official bsky app | |
const collection = 'app.bsky.feed.post'; | |
return { | |
repo, | |
collection, | |
rkey | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment