Skip to content

Commit a682320

Browse files
fix: updated the mute and unmute api (#48)
1 parent 2fc985a commit a682320

9 files changed

Lines changed: 82 additions & 116 deletions

File tree

packages/client/src/user/index.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ import type { AppBskyFeedGetTimeline } from '@tsky/lexicons';
22
import { Actor } from '~/bsky/actor';
33
import type { RPCOptions } from '~/types';
44
import { Paginator } from '~/utils';
5-
import {
6-
MuteUnmuteActor,
7-
MuteUnmuteActorList,
8-
MuteUnmuteThread,
9-
} from './mute_unmute';
5+
import { Mute } from './mute';
106
import { Muted } from './muted';
117
import { Preferences } from './preferences';
128
import { Suggestion } from './suggestion';
9+
import { Unmute } from './unmute';
1310

1411
export class User extends Actor {
1512
get preferences() {
@@ -58,26 +55,11 @@ export class User extends Actor {
5855
return new Suggestion(this.client);
5956
}
6057

61-
/** ----- */
62-
63-
/**
64-
* Mute or unmute a thread
65-
*/
66-
thread(thread: string) {
67-
return new MuteUnmuteThread(this.client, thread);
58+
get mute() {
59+
return new Mute(this.client);
6860
}
6961

70-
/**
71-
* Mute or unmute an actor
72-
*/
73-
actor(identifier: string) {
74-
return new MuteUnmuteActor(this.client, identifier);
75-
}
76-
77-
/**
78-
* Mute or unmute an actor list
79-
*/
80-
actorList(identifier: string) {
81-
return new MuteUnmuteActorList(this.client, identifier);
62+
get unmute() {
63+
return new Unmute(this.client);
8264
}
8365
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './mute';
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type { Client } from '~/tsky/client';
2+
import type { RPCOptions } from '~/types';
3+
4+
export class Mute {
5+
constructor(private client: Client) {}
6+
7+
/**
8+
* Creates a mute relationship for the specified account. Mutes are private in Bluesky.
9+
*/
10+
actor(identifier: string, options: RPCOptions = {}) {
11+
return this.client.call('app.bsky.graph.muteActor', {
12+
data: { actor: identifier },
13+
...options,
14+
});
15+
}
16+
17+
/**
18+
* Mutes a thread preventing notifications from the thread and any of its children. Mutes are private in Bluesky.
19+
*/
20+
thread(identifier: string, options: RPCOptions = {}) {
21+
return this.client.call('app.bsky.graph.muteThread', {
22+
data: { root: identifier },
23+
...options,
24+
});
25+
}
26+
27+
/**
28+
* Mute an entire list (specified by AT-URI) of actors. This creates a mute relationship for all actors
29+
* on the specified list. Mutes are private on Bluesky.
30+
*/
31+
actorList(identifier: string, options: RPCOptions = {}) {
32+
return this.client.call('app.bsky.graph.muteActorList', {
33+
data: { list: identifier },
34+
...options,
35+
});
36+
}
37+
}

packages/client/src/user/mute_unmute/actor.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

packages/client/src/user/mute_unmute/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/client/src/user/mute_unmute/list.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

packages/client/src/user/mute_unmute/thread.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './unmute';
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type { Client } from '~/tsky/client';
2+
import type { RPCOptions } from '~/types';
3+
4+
export class Unmute {
5+
constructor(private client: Client) {}
6+
7+
/**
8+
* Unmutes the specified account.
9+
*/
10+
actor(identifier: string, options: RPCOptions = {}) {
11+
return this.client.call('app.bsky.graph.unmuteActor', {
12+
data: { actor: identifier },
13+
...options,
14+
});
15+
}
16+
17+
/**
18+
* Unmutes the specified thread.
19+
*/
20+
thread(identifier: string, options: RPCOptions = {}) {
21+
return this.client.call('app.bsky.graph.unmuteThread', {
22+
data: { root: identifier },
23+
...options,
24+
});
25+
}
26+
27+
/**
28+
* Unmute an entire list (specified by AT-URI) of actors. This removes the mute relationship for all actors
29+
* on the specified list.
30+
*/
31+
actorList(identifier: string, options: RPCOptions = {}) {
32+
return this.client.call('app.bsky.graph.unmuteActorList', {
33+
data: { list: identifier },
34+
...options,
35+
});
36+
}
37+
}

0 commit comments

Comments
 (0)