Created
March 7, 2025 11:26
-
-
Save mozzius/45785e5661259f0ca53c4dd6add714a3 to your computer and use it in GitHub Desktop.
Update atproto labeller declaration
This file contains hidden or 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 { AppBskyLabelerService, AtpAgent } from "@atproto/api"; | |
const agent = new AtpAgent({ | |
service: "https://bsky.social", | |
}); | |
async function main() { | |
await agent.login({ | |
identifier: "<username>", | |
password: "<password>", | |
}); | |
const record = await agent.com.atproto.repo.getRecord({ | |
repo: agent.session!.did, | |
rkey: 'self', | |
collection: 'app.bsky.labeler.service' | |
}); | |
const value = record.data.value as AppBskyLabelerService.Record | |
await agent.app.bsky.labeler.service.delete({ | |
repo: agent.session!.did, | |
rkey: 'self' | |
}) | |
await agent.app.bsky.labeler.service.create({ | |
repo: agent.session!.did, | |
rkey: 'self' | |
}, { | |
$type: 'app.bsky.labeler.service', | |
policies: value.policies, | |
subjectTypes: ['record'], | |
subjectCollections: ['app.bsky.feed.post'], | |
reasonTypes: [ 'com.atproto.moderation.defs#reasonSpam', ], | |
createdAt: new Date().toISOString() | |
} satisfies AppBskyLabelerService.Record) | |
console.log('Updated ✨') | |
} | |
main().catch(console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment