Blocking users
Blocking a user prevents interaction and hides the user from the client experience. Blocked accounts will not be able to like, reply, mention, or follow you. Their posts, replies, and profile in search will also be hidden from you. Blocks are public.
Blocking users is as simple as muting, but requires creating a record directly.
- Typescript
- Python
agent.app.bsky.graph.block.create
const { uri } = await agent.app.bsky.graph.block.create(
{ repo: agent.session.did },
{
subject: blockingUserDid,
createdAt: new Date().toISOString()
},
)
client.app.bsky.graph.block.create
block_record = models.AppBskyGraphBlock.Record(
subject=blocked_user_did,
created_at=client.get_current_time_iso()
)
uri = client.app.bsky.graph.block.create(client.me.did, block_record).uri
The agent.app.bsky.graph.block.create
method takes two position parameters.
First, the repo:
Parameter | Type | Description | Required |
---|---|---|---|
repo | string | The DID of the authenticated user | Yes |
And the block record itself:
Parameter | Type | Description | Required |
---|---|---|---|
subject | string | The DID of the user to block | Yes |
createdAt | string | The current timestamp | Yes |
Unblocking a user
Similar to likes and follows, unblocking a user is as simple as deleting the record.
- Typescript
- Python
agent.app.bsky.graph.block.delete
import { AtUri } from '@atproto/api'
const { rkey } = new AtUri(uri)
await agent.app.bsky.graph.block.delete(
{
repo: agent.session.did,
rkey,
},
)
client.app.bsky.graph.block.delete
from atproto import AtUri
rkey = AtUri.from_str(uri).rkey
client.app.bsky.graph.block.delete(client.me.did, rkey)
Parameter | Type | Description | Required |
---|---|---|---|
repo | string | The DID of the authenticated user | Yes |
rkey | string | The record key (rkey) of the block record | Yes |