@@ -18,6 +18,8 @@ import {
18
18
QueryModerationConfigsFilters ,
19
19
QueryModerationConfigsSort ,
20
20
Pager ,
21
+ CustomCheckFlag ,
22
+ ReviewQueueItem ,
21
23
} from './types' ;
22
24
import { StreamChat } from './client' ;
23
25
import { normalizeQuerySort } from './utils' ;
@@ -255,4 +257,49 @@ export class Moderation<StreamChatGenerics extends ExtendableGenerics = DefaultG
255
257
options,
256
258
} ) ;
257
259
}
260
+
261
+ /**
262
+ *
263
+ * @param {string } entityType string Type of entity to be checked E.g., stream:user, stream:chat:v1:message, or any custom string
264
+ * @param {string } entityID string ID of the entity to be checked. This is mainly for tracking purposes
265
+ * @param {string } entityCreatorID string ID of the entity creator
266
+ * @param {object } moderationPayload object Content to be checked for moderation. E.g., { texts: ['text1', 'text2'], images: ['image1', 'image2']}
267
+ * @param {Array } moderationPayload.texts array Array of texts to be checked for moderation
268
+ * @param {Array } moderationPayload.images array Array of images to be checked for moderation
269
+ * @param {Array } moderationPayload.videos array Array of videos to be checked for moderation
270
+ * @param {Array<CustomCheckFlag> } flags Array of CustomCheckFlag to be passed to flag the entity
271
+ * @returns
272
+ */
273
+ async addCustomFlags (
274
+ entityType : string ,
275
+ entityID : string ,
276
+ entityCreatorID : string ,
277
+ moderationPayload : {
278
+ images ?: string [ ] ;
279
+ texts ?: string [ ] ;
280
+ videos ?: string [ ] ;
281
+ } ,
282
+ flags : CustomCheckFlag [ ] ,
283
+ ) {
284
+ return await this . client . post < { id : string ; item : ReviewQueueItem ; status : string } & APIResponse > (
285
+ this . client . baseURL + `/api/v2/moderation/custom_check` ,
286
+ {
287
+ entity_type : entityType ,
288
+ entity_id : entityID ,
289
+ entity_creator_id : entityCreatorID ,
290
+ moderation_payload : moderationPayload ,
291
+ flags,
292
+ } ,
293
+ ) ;
294
+ }
295
+
296
+ /**
297
+ * Add custom flags to a message
298
+ * @param {string } messageID Message ID to be flagged
299
+ * @param {Array<CustomCheckFlag> } flags Array of CustomCheckFlag to be passed to flag the message
300
+ * @returns
301
+ */
302
+ async addCustomMessageFlags ( messageID : string , flags : CustomCheckFlag [ ] ) {
303
+ return await this . addCustomFlags ( MODERATION_ENTITY_TYPES . message , messageID , '' , { } , flags ) ;
304
+ }
258
305
}
0 commit comments