From c6a5ab21bb18ce8886512d84c5323592f4de2093 Mon Sep 17 00:00:00 2001 From: Vishal Narkhede Date: Tue, 23 Jul 2024 13:20:56 +0200 Subject: [PATCH] feat: moderation submit action endpoint (#1329) --- src/moderation.ts | 12 ++++++++++++ src/types.ts | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/moderation.ts b/src/moderation.ts index cefcc1e68..824430062 100644 --- a/src/moderation.ts +++ b/src/moderation.ts @@ -14,6 +14,7 @@ import { ModerationFlagOptions, ModerationMuteOptions, GetUserModerationReportOptions, + SubmitActionOptions, } from './types'; import { StreamChat } from './client'; import { normalizeQuerySort } from './utils'; @@ -179,4 +180,15 @@ export class Moderation(this.client.baseURL + '/api/v2/moderation/config/' + key); } + + async submitAction(actionType: string, itemID: string, options: SubmitActionOptions = {}) { + return await this.client.post<{ item_id: string } & APIResponse>( + this.client.baseURL + '/api/v2/moderation/submit_action', + { + action_type: actionType, + item_id: itemID, + ...options, + }, + ); + } } diff --git a/src/types.ts b/src/types.ts index 0e4833e1e..c96d8b31b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3215,6 +3215,27 @@ export type ReviewQueueItem = { updated_at: string; }; +export type SubmitActionOptions = { + ban?: { + channel_ban_only?: boolean; + reason?: string; + timeout?: number; + }; + delete_message?: { + hard_delete?: boolean; + }; + delete_user?: { + delete_conversation_channels?: boolean; + hard_delete?: boolean; + mark_messages_deleted?: boolean; + }; + restore?: {}; + unban?: { + channel_cid?: string; + }; + user_id?: string; +}; + export type GetUserModerationReportResponse = { user: UserResponse; user_blocks?: Array<{