Skip to content

Instantly share code, notes, and snippets.

@trozzelle
Created May 13, 2023 05:36
Show Gist options
  • Save trozzelle/4f2f0025ab49e0f4df8cc4871b64456e to your computer and use it in GitHub Desktop.
Save trozzelle/4f2f0025ab49e0f4df8cc4871b64456e to your computer and use it in GitHub Desktop.
Delete all blocks
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