Created
May 13, 2023 05:36
-
-
Save trozzelle/4f2f0025ab49e0f4df8cc4871b64456e to your computer and use it in GitHub Desktop.
Delete all blocks
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
import {authenticateBsky, getBlocks, deleteBlock} from "./api.js"; | |
const user = | |
const pass = | |
async function main() { | |
const agent = await authenticateBsky() | |
const {data: {did}} = await agent.resolveHandle({handle:user}) | |
const blocks = await getBlocks(agent, did) | |
const rkeys = blocks.map((block) => { | |
let uri = block.uri | |
let parts = uri.split('/'); | |
let lastSegment = parts[parts.length - 1]; | |
console.log(lastSegment); // Output: 3jvexyj3js72n | |
return lastSegment | |
}) | |
for (const key in rkeys) { | |
await deleteBlock(agent, agent.session.did, rkeys[key]) | |
} | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment