Skip to content

Commit

Permalink
Merge pull request #34 from bluesky-social/eric/blocks-mutes
Browse files Browse the repository at this point in the history
Add Blocking and Muting tutorials
  • Loading branch information
emilyliu7321 authored Jan 28, 2024
2 parents 0c0fb92 + b50f46e commit 4b7ebef
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 2 deletions.
63 changes: 62 additions & 1 deletion docs/tutorials/blocking.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,67 @@
sidebar_position: 9
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Blocking users

TODO
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](/blog/block-implementation).

Blocking users is as simple as muting, but requires creating a record directly.

<Tabs groupId="sdk">
<TabItem value="ts" label="Typescript">
```typescript title="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()
},
)
```
</TabItem>
</Tabs>

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.

<Tabs groupId="sdk">
<TabItem value="ts" label="Typescript">
```typescript title="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,
},
)
```

</TabItem>
</Tabs>

| Parameter | Type | Description | Required |
| --------- | -------- | ----------------------------------------- | -------- |
| `repo` | `string` | The DID of the authenticated user | Yes |
| `rkey` | `string` | The record key (rkey) of the block record | Yes |
34 changes: 33 additions & 1 deletion docs/tutorials/muting.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@
sidebar_position: 8
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Muting users

TODO
Muting a user hides their posts from your feeds. Mutes are private, and stored
on your PDS. Muting a user is as easy as liking a post or following a user.

<Tabs groupId="sdk">
<TabItem value="ts" label="Typescript">
```typescript title="agent.mute"
await agent.mute(did)
```
</TabItem>
</Tabs>

| Parameter | Type | Description | Required |
| --------- | -------- | --------------------------- | -------- |
| `did` | `string` | The DID of the user to mute | Yes |

## Unmuting a user

Easy peasy:

<Tabs groupId="sdk">
<TabItem value="ts" label="Typescript">
```typescript title="agent.mute"
await agent.unmute(did)
```
</TabItem>
</Tabs>

| Parameter | Type | Description | Required |
| --------- | -------- | ------------------------------ | -------- |
| `did` | `string` | The DID of the user to un-mute | Yes |

0 comments on commit 4b7ebef

Please sign in to comment.