Skip to content

Commit

Permalink
feat: moderation submit action endpoint (#1329)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnarkhede committed Jul 23, 2024
1 parent 2276b85 commit c6a5ab2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/moderation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
ModerationFlagOptions,
ModerationMuteOptions,
GetUserModerationReportOptions,
SubmitActionOptions,
} from './types';
import { StreamChat } from './client';
import { normalizeQuerySort } from './utils';
Expand Down Expand Up @@ -179,4 +180,15 @@ export class Moderation<StreamChatGenerics extends ExtendableGenerics = DefaultG
async getConfig(key: string) {
return await this.client.get<GetConfigResponse>(this.client.baseURL + '/api/v2/moderation/config/' + key);
}

async submitAction(actionType: string, itemID: string, options: SubmitActionOptions = {}) {
return await this.client.post<{ item_id: string } & APIResponse>(
this.client.baseURL + '/api/v2/moderation/submit_action',
{
action_type: actionType,
item_id: itemID,
...options,
},
);
}
}
21 changes: 21 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3215,6 +3215,27 @@ export type ReviewQueueItem = {
updated_at: string;
};

export type SubmitActionOptions = {
ban?: {
channel_ban_only?: boolean;
reason?: string;
timeout?: number;
};
delete_message?: {
hard_delete?: boolean;
};
delete_user?: {
delete_conversation_channels?: boolean;
hard_delete?: boolean;
mark_messages_deleted?: boolean;
};
restore?: {};
unban?: {
channel_cid?: string;
};
user_id?: string;
};

export type GetUserModerationReportResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
user: UserResponse<StreamChatGenerics>;
user_blocks?: Array<{
Expand Down

0 comments on commit c6a5ab2

Please sign in to comment.