diff --git a/src/moderation.ts b/src/moderation.ts index f166670f0..0bc339d56 100644 --- a/src/moderation.ts +++ b/src/moderation.ts @@ -18,6 +18,8 @@ import { QueryModerationConfigsFilters, QueryModerationConfigsSort, Pager, + CustomCheckFlag, + ReviewQueueItem, } from './types'; import { StreamChat } from './client'; import { normalizeQuerySort } from './utils'; @@ -255,4 +257,49 @@ export class Moderation} flags Array of CustomCheckFlag to be passed to flag the entity + * @returns + */ + async addCustomFlags( + entityType: string, + entityID: string, + entityCreatorID: string, + moderationPayload: { + images?: string[]; + texts?: string[]; + videos?: string[]; + }, + flags: CustomCheckFlag[], + ) { + return await this.client.post<{ id: string; item: ReviewQueueItem; status: string } & APIResponse>( + this.client.baseURL + `/api/v2/moderation/custom_check`, + { + entity_type: entityType, + entity_id: entityID, + entity_creator_id: entityCreatorID, + moderation_payload: moderationPayload, + flags, + }, + ); + } + + /** + * Add custom flags to a message + * @param {string} messageID Message ID to be flagged + * @param {Array} flags Array of CustomCheckFlag to be passed to flag the message + * @returns + */ + async addCustomMessageFlags(messageID: string, flags: CustomCheckFlag[]) { + return await this.addCustomFlags(MODERATION_ENTITY_TYPES.message, messageID, '', {}, flags); + } } diff --git a/src/types.ts b/src/types.ts index 2bd1cd5d0..342e40302 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3420,6 +3420,14 @@ export type ReviewQueueItem = { updated_at: string; }; +export type CustomCheckFlag = { + type: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + custom?: Record[]; + labels?: string[]; + reason?: string; +}; + export type SubmitActionOptions = { ban?: { channel_ban_only?: boolean;