Skip to content

Commit c6a5ab2

Browse files
feat: moderation submit action endpoint (#1329)
1 parent 2276b85 commit c6a5ab2

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/moderation.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
ModerationFlagOptions,
1515
ModerationMuteOptions,
1616
GetUserModerationReportOptions,
17+
SubmitActionOptions,
1718
} from './types';
1819
import { StreamChat } from './client';
1920
import { normalizeQuerySort } from './utils';
@@ -179,4 +180,15 @@ export class Moderation<StreamChatGenerics extends ExtendableGenerics = DefaultG
179180
async getConfig(key: string) {
180181
return await this.client.get<GetConfigResponse>(this.client.baseURL + '/api/v2/moderation/config/' + key);
181182
}
183+
184+
async submitAction(actionType: string, itemID: string, options: SubmitActionOptions = {}) {
185+
return await this.client.post<{ item_id: string } & APIResponse>(
186+
this.client.baseURL + '/api/v2/moderation/submit_action',
187+
{
188+
action_type: actionType,
189+
item_id: itemID,
190+
...options,
191+
},
192+
);
193+
}
182194
}

src/types.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,6 +3215,27 @@ export type ReviewQueueItem = {
32153215
updated_at: string;
32163216
};
32173217

3218+
export type SubmitActionOptions = {
3219+
ban?: {
3220+
channel_ban_only?: boolean;
3221+
reason?: string;
3222+
timeout?: number;
3223+
};
3224+
delete_message?: {
3225+
hard_delete?: boolean;
3226+
};
3227+
delete_user?: {
3228+
delete_conversation_channels?: boolean;
3229+
hard_delete?: boolean;
3230+
mark_messages_deleted?: boolean;
3231+
};
3232+
restore?: {};
3233+
unban?: {
3234+
channel_cid?: string;
3235+
};
3236+
user_id?: string;
3237+
};
3238+
32183239
export type GetUserModerationReportResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
32193240
user: UserResponse<StreamChatGenerics>;
32203241
user_blocks?: Array<{

0 commit comments

Comments
 (0)