diff --git a/src/moderation.ts b/src/moderation.ts index d9be41da4..6cf225f47 100644 --- a/src/moderation.ts +++ b/src/moderation.ts @@ -21,6 +21,7 @@ import { CustomCheckFlag, ReviewQueueItem, QueryConfigsResponse, + RequireAtLeastOne, } from './types'; import { StreamChat } from './client'; import { normalizeQuerySort } from './utils'; @@ -28,6 +29,7 @@ import { normalizeQuerySort } from './utils'; export const MODERATION_ENTITY_TYPES = { user: 'stream:user', message: 'stream:chat:v1:message', + userprofile: 'stream:v1:user_profile', }; // Moderation class provides all the endpoints related to moderation v2. @@ -247,6 +249,7 @@ export class Moderation) { + if (!profile.username && !profile.image) { + throw new Error('Either username or image must be provided'); + } + + const moderationPayload: { images?: string[]; texts?: string[] } = {}; + if (profile.username) { + moderationPayload.texts = [profile.username]; + } + if (profile.image) { + moderationPayload.images = [profile.image]; + } + + return await this.check( + MODERATION_ENTITY_TYPES.userprofile, + userId, + userId, + moderationPayload, + 'user_profile:default', + { + force_sync: true, + test_mode: true, + }, + ); + } + /** * * @param {string} entityType string Type of entity to be checked E.g., stream:user, stream:chat:v1:message, or any custom string