From c6dda4448a06221d52bc452c45981868d2e75bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Janowski?= Date: Wed, 31 Jul 2024 12:31:56 +0200 Subject: [PATCH] feat(lib): deprecate old reporting methods --- lib/src/entities/channel.ts | 8 ++++---- lib/src/entities/message.ts | 5 +++-- lib/src/entities/user.ts | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/src/entities/channel.ts b/lib/src/entities/channel.ts index f29f159..30ae3ca 100644 --- a/lib/src/entities/channel.ts +++ b/lib/src/entities/channel.ts @@ -750,12 +750,12 @@ export class Channel { } /** - * Flagged messages + * Reported messages */ - async getFlaggedMessagesHistory( + async getMessageReportsHistory( params: { startTimetoken?: string; endTimetoken?: string; count?: number } = {} - ) { + ): Promise<{ events: Event<"report">[]; isMore: boolean }> { const channel = `${INTERNAL_MODERATION_PREFIX}${this.id}` return this.chat.getEventsHistory({ ...params, @@ -763,7 +763,7 @@ export class Channel { }) } - listenForFlaggedMessages(callback: (event: Event<"report">) => void) { + streamMessageReports(callback: (event: Event<"report">) => void) { const channel = `${INTERNAL_MODERATION_PREFIX}${this.id}` return this.chat.listenForEvents({ channel, diff --git a/lib/src/entities/message.ts b/lib/src/entities/message.ts index 06e1eb4..a4a231b 100644 --- a/lib/src/entities/message.ts +++ b/lib/src/entities/message.ts @@ -368,7 +368,8 @@ export class Message { await this.chat.pinMessageToChannel(this, channel!) } - async report(reason: string) { + /** @deprecated */ + async DEPRECATED_report(reason: string) { const channel = INTERNAL_ADMIN_CHANNEL const payload = { text: this.text, @@ -380,7 +381,7 @@ export class Message { return await this.chat.emitEvent({ channel, type: "report", payload }) } - async reportOnChannel(reason: string) { + async report(reason: string) { const channel = `${INTERNAL_MODERATION_PREFIX}${this.channelId}` const payload = { text: this.text, diff --git a/lib/src/entities/user.ts b/lib/src/entities/user.ts index 7075085..f00baa0 100644 --- a/lib/src/entities/user.ts +++ b/lib/src/entities/user.ts @@ -218,7 +218,8 @@ export class User { /* * Other */ - async report(reason: string) { + /** @deprecated */ + async DEPRECATED_report(reason: string) { const channel = INTERNAL_ADMIN_CHANNEL const payload = { reason,