Skip to content
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

Moderation configuration multitenancy #1420

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 55 additions & 4 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ import {
PartialUserUpdate,
PermissionAPIResponse,
PermissionsAPIResponse,
PhraseList,
PhraseListResponse,
PollAnswersAPIResponse,
PollData,
PollOptionData,
Expand Down Expand Up @@ -3079,8 +3081,8 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
return this.post<APIResponse>(`${this.baseURL}/blocklists`, blockList);
}

listBlockLists() {
return this.get<APIResponse & { blocklists: BlockListResponse[] }>(`${this.baseURL}/blocklists`);
listBlockLists(data?: { team?: string }) {
return this.get<APIResponse & { blocklists: BlockListResponse[] }>(`${this.baseURL}/blocklists`, data);
}

getBlockList(name: string) {
Expand All @@ -3093,8 +3095,57 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
return this.put<APIResponse>(`${this.baseURL}/blocklists/${encodeURIComponent(name)}`, data);
}

deleteBlockList(name: string) {
return this.delete<APIResponse>(`${this.baseURL}/blocklists/${encodeURIComponent(name)}`);
deleteBlockList(name: string, data: { team?: string }) {
return this.delete<APIResponse>(`${this.baseURL}/blocklists/${encodeURIComponent(name)}`, data);
}

/**
* Creates a new phraselist
* @param {PhraseList} phraseList The phraselist data to create
* @returns {Promise<APIResponse>} API response
*/
createPhraseList(phraseList: PhraseList) {
return this.post<APIResponse>(`${this.baseURL}/phraselists`, phraseList);
}

/**
* Lists all phraselists
* @param {Object} data Optional parameters like team
* @returns {Promise<APIResponse & { phraselists: PhraseListResponse[] }>} List of phraselists
*/
listPhraseLists(data?: { team?: string }) {
return this.get<APIResponse & { phraselists: PhraseListResponse[] }>(`${this.baseURL}/phraselists`, data);
}

/**
* Gets a specific phraselist by name
* @param {string} name The name of the phraselist to retrieve
* @returns {Promise<APIResponse & { phraselist: PhraseListResponse }>} The requested phraselist
*/
getPhraseList(name: string) {
return this.get<APIResponse & { phraselist: PhraseListResponse }>(
`${this.baseURL}/phraselists/${encodeURIComponent(name)}`,
);
}

/**
* Updates an existing phraselist
* @param {string} name The name of the phraselist to update
* @param {Object} data The update data containing phrases array
* @returns {Promise<APIResponse>} API response
*/
updatePhraseList(name: string, data: { phrases: string[] }) {
return this.put<APIResponse>(`${this.baseURL}/phraselists/${encodeURIComponent(name)}`, data);
}

/**
* Deletes a phraselist
* @param {string} name The name of the phraselist to delete
* @param {Object} data Optional parameters like team
* @returns {Promise<APIResponse>} API response
*/
deletePhraseList(name: string, data: { team?: string }) {
return this.delete<APIResponse>(`${this.baseURL}/phraselists/${encodeURIComponent(name)}`, data);
}

exportChannels(request: Array<ExportChannelRequest>, options: ExportChannelOptions = {}) {
Expand Down
12 changes: 12 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ export type BannedUsersResponse<StreamChatGenerics extends ExtendableGenerics =
}>;
};

export type PhraseListResponse = PhraseList & {
created_at?: string;
type?: string;
updated_at?: string;
};

export type BlockListResponse = BlockList & {
created_at?: string;
type?: string;
Expand Down Expand Up @@ -2198,6 +2204,12 @@ export type BlockList = {
validate?: boolean;
};

export type PhraseList = {
name: string;
phrases: string[];
team: string;
};

export type ChannelConfig<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = ChannelConfigFields &
CreatedAtUpdatedAt & {
commands?: CommandVariants<StreamChatGenerics>[];
Expand Down
Loading