Skip to content

Commit 2df58c9

Browse files
Merge branch 'master' of github.com:GetStream/stream-chat-js into rc
2 parents 5797193 + bfe4d59 commit 2df58c9

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,20 @@ property in the formatted message output
8787

8888
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
8989

90+
## [8.58.0](https://github.com/GetStream/stream-chat-js/compare/v8.57.6...v8.58.0) (2025-04-01)
91+
92+
93+
### Features
94+
95+
* [CHA-375] add draft messages api ([#1490](https://github.com/GetStream/stream-chat-js/issues/1490)) ([3a7f732](https://github.com/GetStream/stream-chat-js/commit/3a7f7327cb23bdf8578f9cffa885bcd1594f1cde))
96+
* user profile check endpoint ([#1503](https://github.com/GetStream/stream-chat-js/issues/1503)) ([8114c22](https://github.com/GetStream/stream-chat-js/commit/8114c223b2a6650a89790e64a236d1a03cf64c3b))
97+
98+
99+
### Bug Fixes
100+
101+
* provide a way for a suffix to be added to wsUrl ([#1497](https://github.com/GetStream/stream-chat-js/issues/1497)) ([d14d0ff](https://github.com/GetStream/stream-chat-js/commit/d14d0ff1df942ab8ef4493c8ad7feb7601b951f2))
102+
* use URLSearchParams when building WS url ([#1498](https://github.com/GetStream/stream-chat-js/issues/1498)) ([9413433](https://github.com/GetStream/stream-chat-js/commit/9413433c8544b8dfa96a878847fe94954935d529))
103+
90104
### [8.57.6](https://github.com/GetStream/stream-chat-js/compare/v8.57.5...v8.57.6) (2025-03-03)
91105

92106

src/moderation.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
QueryConfigsResponse,
1313
QueryModerationConfigsFilters,
1414
QueryModerationConfigsSort,
15+
RequireAtLeastOne,
1516
ReviewQueueFilters,
1617
ReviewQueueItem,
1718
ReviewQueuePaginationOptions,
@@ -26,6 +27,7 @@ import { normalizeQuerySort } from './utils';
2627
export const MODERATION_ENTITY_TYPES = {
2728
user: 'stream:user',
2829
message: 'stream:chat:v1:message',
30+
userprofile: 'stream:v1:user_profile',
2931
};
3032

3133
// Moderation class provides all the endpoints related to moderation v2.
@@ -270,6 +272,7 @@ export class Moderation {
270272
configKey: string,
271273
options?: {
272274
force_sync?: boolean;
275+
test_mode?: boolean;
273276
},
274277
) {
275278
return await this.client.post(this.client.baseURL + `/api/v2/moderation/check`, {
@@ -282,6 +285,60 @@ export class Moderation {
282285
});
283286
}
284287

288+
/**
289+
* Experimental: Check user profile
290+
*
291+
* Warning: This is an experimental feature and the API is subject to change.
292+
*
293+
* This function is used to check a user profile for moderation.
294+
* This will not create any review queue items for the user profile.
295+
* You can just use this to check whether to allow a certain user profile to be created or not.
296+
*
297+
* Example:
298+
*
299+
* ```ts
300+
* const res = await client.moderation.checkUserProfile(userId, { username: "fuck_boy_001", image: "https://example.com/profile.jpg" });
301+
* if (res.recommended_action === "remove") {
302+
* // Block the user profile from being created
303+
* } else {
304+
* // Allow the user profile to be created
305+
* }
306+
* ```
307+
*
308+
* @param userId
309+
* @param profile.username
310+
* @param profile.image
311+
* @returns
312+
*/
313+
async checkUserProfile(
314+
userId: string,
315+
profile: RequireAtLeastOne<{ image?: string; username?: string }>,
316+
) {
317+
if (!profile.username && !profile.image) {
318+
throw new Error('Either username or image must be provided');
319+
}
320+
321+
const moderationPayload: { images?: string[]; texts?: string[] } = {};
322+
if (profile.username) {
323+
moderationPayload.texts = [profile.username];
324+
}
325+
if (profile.image) {
326+
moderationPayload.images = [profile.image];
327+
}
328+
329+
return await this.check(
330+
MODERATION_ENTITY_TYPES.userprofile,
331+
userId,
332+
userId,
333+
moderationPayload,
334+
'user_profile:default',
335+
{
336+
force_sync: true,
337+
test_mode: true,
338+
},
339+
);
340+
}
341+
285342
/**
286343
*
287344
* @param {string} entityType string Type of entity to be checked E.g., stream:user, stream:chat:v1:message, or any custom string

0 commit comments

Comments
 (0)