-
Notifications
You must be signed in to change notification settings - Fork 77
feat: user profile check endpoint #1503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
1d8f3bb
79d888a
7379c02
c06c0e9
9b3fec0
3e3c113
d6ccd56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,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 +248,7 @@ export class Moderation<StreamChatGenerics extends ExtendableGenerics = DefaultG | |||||||||||||||||
| configKey: string, | ||||||||||||||||||
| options?: { | ||||||||||||||||||
| force_sync?: boolean; | ||||||||||||||||||
| test_mode?: boolean; | ||||||||||||||||||
| }, | ||||||||||||||||||
| ) { | ||||||||||||||||||
| return await this.client.post(this.client.baseURL + `/api/v2/moderation/check`, { | ||||||||||||||||||
|
|
@@ -259,6 +261,52 @@ export class Moderation<StreamChatGenerics extends ExtendableGenerics = DefaultG | |||||||||||||||||
| }); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Experimental: Check user profile | ||||||||||||||||||
| * | ||||||||||||||||||
| * Warning: This is an experimental feature and the API is subject to change. | ||||||||||||||||||
| * | ||||||||||||||||||
| * This function is used to check a user profile for moderation. | ||||||||||||||||||
| * This will not create any review queue items for the user profile. | ||||||||||||||||||
| * You can just use this to check weather to allow certain user profile to be created or not. | ||||||||||||||||||
| * | ||||||||||||||||||
| * Example: | ||||||||||||||||||
| * | ||||||||||||||||||
| * ```ts | ||||||||||||||||||
| * const res = await client.moderation.checkUserProfile(userId, { username: "fuck_boy_001", profileImage: "https://example.com/profile.jpg" }); | ||||||||||||||||||
| * if (res.recommended_action === "remove") { | ||||||||||||||||||
| * // Block the user profile from being created | ||||||||||||||||||
| * } else { | ||||||||||||||||||
| * // Allow the user profile to be created | ||||||||||||||||||
| * } | ||||||||||||||||||
| * ``` | ||||||||||||||||||
| * | ||||||||||||||||||
| * @param userId | ||||||||||||||||||
| * @param username | ||||||||||||||||||
| * @param profileImage | ||||||||||||||||||
| * @returns | ||||||||||||||||||
| */ | ||||||||||||||||||
| async checkUserProfile(userId: string, profile: { profileImage?: string; username?: string } = {}) { | ||||||||||||||||||
| if (!profile.username && !profile.profileImage) { | ||||||||||||||||||
| throw new Error('Either username or profileImage must be provided'); | ||||||||||||||||||
| } | ||||||||||||||||||
|
||||||||||||||||||
| async checkUserProfile(userId: string, profile: { profileImage?: string; username?: string } = {}) { | |
| if (!profile.username && !profile.profileImage) { | |
| throw new Error('Either username or profileImage must be provided'); | |
| } | |
| async checkUserProfile(userId: string, profile: RequireAtLeastOne<{ profile: string; image: string }>) { | |
| if (!profile.username && !profile.image) { | |
| throw new Error('Either profile.username or profile.image must be provided'); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also - nit; changed profileImage to image
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| texts: [profile.username as string], | |
| images: [profile.profileImage as string], | |
| texts: [profile.username as string], | |
| images: [profile.profileImage as string], |
One of these might become: [undefined] - is that okay?
Uh oh!
There was an error while loading. Please reload this page.