From 2513ad19cfc9e14cda68b0261afc938ba7f1a3a0 Mon Sep 17 00:00:00 2001 From: Aditya Mathur Date: Wed, 22 Jan 2025 11:45:51 +0530 Subject: [PATCH] fix: updated the mute and unmute api --- packages/client/src/user/index.ts | 30 +++------------ packages/client/src/user/mute/index.ts | 1 + packages/client/src/user/mute/mute.ts | 37 +++++++++++++++++++ packages/client/src/user/mute_unmute/actor.ts | 29 --------------- packages/client/src/user/mute_unmute/index.ts | 3 -- packages/client/src/user/mute_unmute/list.ts | 31 ---------------- .../client/src/user/mute_unmute/thread.ts | 29 --------------- packages/client/src/user/unmute/index.ts | 1 + packages/client/src/user/unmute/unmute.ts | 37 +++++++++++++++++++ 9 files changed, 82 insertions(+), 116 deletions(-) create mode 100644 packages/client/src/user/mute/index.ts create mode 100644 packages/client/src/user/mute/mute.ts delete mode 100644 packages/client/src/user/mute_unmute/actor.ts delete mode 100644 packages/client/src/user/mute_unmute/index.ts delete mode 100644 packages/client/src/user/mute_unmute/list.ts delete mode 100644 packages/client/src/user/mute_unmute/thread.ts create mode 100644 packages/client/src/user/unmute/index.ts create mode 100644 packages/client/src/user/unmute/unmute.ts diff --git a/packages/client/src/user/index.ts b/packages/client/src/user/index.ts index 4c0325b..99e2809 100644 --- a/packages/client/src/user/index.ts +++ b/packages/client/src/user/index.ts @@ -2,14 +2,11 @@ import type { AppBskyFeedGetTimeline } from '@tsky/lexicons'; import { Actor } from '~/bsky/actor'; import type { RPCOptions } from '~/types'; import { Paginator } from '~/utils'; -import { - MuteUnmuteActor, - MuteUnmuteActorList, - MuteUnmuteThread, -} from './mute_unmute'; +import { Mute } from './mute'; import { Muted } from './muted'; import { Preferences } from './preferences'; import { Suggestion } from './suggestion'; +import { Unmute } from './unmute'; export class User extends Actor { get preferences() { @@ -58,26 +55,11 @@ export class User extends Actor { return new Suggestion(this.client); } - /** ----- */ - - /** - * Mute or unmute a thread - */ - thread(thread: string) { - return new MuteUnmuteThread(this.client, thread); + get mute() { + return new Mute(this.client); } - /** - * Mute or unmute an actor - */ - actor(identifier: string) { - return new MuteUnmuteActor(this.client, identifier); - } - - /** - * Mute or unmute an actor list - */ - actorList(identifier: string) { - return new MuteUnmuteActorList(this.client, identifier); + get unmute() { + return new Unmute(this.client); } } diff --git a/packages/client/src/user/mute/index.ts b/packages/client/src/user/mute/index.ts new file mode 100644 index 0000000..c456722 --- /dev/null +++ b/packages/client/src/user/mute/index.ts @@ -0,0 +1 @@ +export * from './mute'; diff --git a/packages/client/src/user/mute/mute.ts b/packages/client/src/user/mute/mute.ts new file mode 100644 index 0000000..a6c65d8 --- /dev/null +++ b/packages/client/src/user/mute/mute.ts @@ -0,0 +1,37 @@ +import type { Client } from '~/tsky/client'; +import type { RPCOptions } from '~/types'; + +export class Mute { + constructor(private client: Client) {} + + /** + * Creates a mute relationship for the specified account. Mutes are private in Bluesky. + */ + actor(identifier: string, options: RPCOptions = {}) { + return this.client.call('app.bsky.graph.muteActor', { + data: { actor: identifier }, + ...options, + }); + } + + /** + * Mutes a thread preventing notifications from the thread and any of its children. Mutes are private in Bluesky. + */ + thread(identifier: string, options: RPCOptions = {}) { + return this.client.call('app.bsky.graph.muteThread', { + data: { root: identifier }, + ...options, + }); + } + + /** + * Mute an entire list (specified by AT-URI) of actors. This creates a mute relationship for all actors + * on the specified list. Mutes are private on Bluesky. + */ + actorList(identifier: string, options: RPCOptions = {}) { + return this.client.call('app.bsky.graph.muteActorList', { + data: { list: identifier }, + ...options, + }); + } +} diff --git a/packages/client/src/user/mute_unmute/actor.ts b/packages/client/src/user/mute_unmute/actor.ts deleted file mode 100644 index f207c65..0000000 --- a/packages/client/src/user/mute_unmute/actor.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { Client } from '~/tsky/client'; -import type { RPCOptions } from '~/types'; - -export class MuteUnmuteActor { - constructor( - private client: Client, - private identifier: string, - ) {} - - /** - * Creates a mute relationship for the specified account. Mutes are private in Bluesky. - */ - mute(options: RPCOptions = {}) { - return this.client.call('app.bsky.graph.muteActor', { - data: { actor: this.identifier }, - ...options, - }); - } - - /** - * Unmutes the specified account. - */ - unmute(options: RPCOptions = {}) { - return this.client.call('app.bsky.graph.unmuteActor', { - data: { actor: this.identifier }, - ...options, - }); - } -} diff --git a/packages/client/src/user/mute_unmute/index.ts b/packages/client/src/user/mute_unmute/index.ts deleted file mode 100644 index e8739c5..0000000 --- a/packages/client/src/user/mute_unmute/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './actor'; -export * from './list'; -export * from './thread'; diff --git a/packages/client/src/user/mute_unmute/list.ts b/packages/client/src/user/mute_unmute/list.ts deleted file mode 100644 index 3ad1145..0000000 --- a/packages/client/src/user/mute_unmute/list.ts +++ /dev/null @@ -1,31 +0,0 @@ -import type { Client } from '~/tsky/client'; -import type { RPCOptions } from '~/types'; - -export class MuteUnmuteActorList { - constructor( - private client: Client, - private identifier: string, - ) {} - - /** - * Mute an entire list (specified by AT-URI) of actors. This creates a mute relationship for all actors - * on the specified list. Mutes are private on Bluesky. - */ - mute(options: RPCOptions = {}) { - return this.client.call('app.bsky.graph.muteActorList', { - data: { list: this.identifier }, - ...options, - }); - } - - /** - * Unmute an entire list (specified by AT-URI) of actors. This removes the mute relationship for all actors - * on the specified list. - */ - unmute(options: RPCOptions = {}) { - return this.client.call('app.bsky.graph.unmuteActorList', { - data: { list: this.identifier }, - ...options, - }); - } -} diff --git a/packages/client/src/user/mute_unmute/thread.ts b/packages/client/src/user/mute_unmute/thread.ts deleted file mode 100644 index 56621f3..0000000 --- a/packages/client/src/user/mute_unmute/thread.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type { Client } from '~/tsky/client'; -import type { RPCOptions } from '~/types'; - -export class MuteUnmuteThread { - constructor( - private client: Client, - private thread: string, - ) {} - - /** - * Mutes a thread preventing notifications from the thread and any of its children. Mutes are private in Bluesky. - */ - mute(options: RPCOptions = {}) { - return this.client.call('app.bsky.graph.muteThread', { - data: { root: this.thread }, - ...options, - }); - } - - /** - * Unmutes the specified thread. - */ - unmute(options: RPCOptions = {}) { - return this.client.call('app.bsky.graph.unmuteThread', { - data: { root: this.thread }, - ...options, - }); - } -} diff --git a/packages/client/src/user/unmute/index.ts b/packages/client/src/user/unmute/index.ts new file mode 100644 index 0000000..42ac0a4 --- /dev/null +++ b/packages/client/src/user/unmute/index.ts @@ -0,0 +1 @@ +export * from './unmute'; diff --git a/packages/client/src/user/unmute/unmute.ts b/packages/client/src/user/unmute/unmute.ts new file mode 100644 index 0000000..c100a66 --- /dev/null +++ b/packages/client/src/user/unmute/unmute.ts @@ -0,0 +1,37 @@ +import type { Client } from '~/tsky/client'; +import type { RPCOptions } from '~/types'; + +export class Unmute { + constructor(private client: Client) {} + + /** + * Unmutes the specified account. + */ + actor(identifier: string, options: RPCOptions = {}) { + return this.client.call('app.bsky.graph.unmuteActor', { + data: { actor: identifier }, + ...options, + }); + } + + /** + * Unmutes the specified thread. + */ + thread(identifier: string, options: RPCOptions = {}) { + return this.client.call('app.bsky.graph.unmuteThread', { + data: { root: identifier }, + ...options, + }); + } + + /** + * Unmute an entire list (specified by AT-URI) of actors. This removes the mute relationship for all actors + * on the specified list. + */ + actorList(identifier: string, options: RPCOptions = {}) { + return this.client.call('app.bsky.graph.unmuteActorList', { + data: { list: identifier }, + ...options, + }); + } +}