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

feat: multitenant blocklist support #1450

Merged
merged 11 commits into from
Jan 29, 2025
59 changes: 53 additions & 6 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3101,26 +3101,73 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
});
}

/**
* Creates a new block list
*
* @param {BlockList} blockList - The block list to create
* @param {string} blockList.name - The name of the block list
* @param {string[]} blockList.words - List of words to block
* @param {string} [blockList.team] - Team ID the block list belongs to
*
* @returns {Promise<APIResponse>} The server response
*/
createBlockList(blockList: BlockList) {
return this.post<APIResponse>(`${this.baseURL}/blocklists`, blockList);
}

listBlockLists() {
return this.get<APIResponse & { blocklists: BlockListResponse[] }>(`${this.baseURL}/blocklists`);
/**
* Lists all block lists
*
* @param {Object} [data] - Query parameters
* @param {string} [data.team] - Team ID to filter block lists by
*
* @returns {Promise<APIResponse & {blocklists: BlockListResponse[]}>} Response containing array of block lists
*/
listBlockLists(data?: { team?: string }) {
return this.get<APIResponse & { blocklists: BlockListResponse[] }>(`${this.baseURL}/blocklists`, data);
}

getBlockList(name: string) {
/**
* Gets a specific block list
*
* @param {string} name - The name of the block list to retrieve
* @param {Object} [data] - Query parameters
* @param {string} [data.team] - Team ID that blocklist belongs to
*
* @returns {Promise<APIResponse & {blocklist: BlockListResponse}>} Response containing the block list
*/
getBlockList(name: string, data?: { team?: string }) {
return this.get<APIResponse & { blocklist: BlockListResponse }>(
`${this.baseURL}/blocklists/${encodeURIComponent(name)}`,
data,
);
}

updateBlockList(name: string, data: { words: string[] }) {
/**
* Updates an existing block list
*
* @param {string} name - The name of the block list to update
* @param {Object} data - The update data
* @param {string[]} data.words - New list of words to block
* @param {string} [data.team] - Team ID that blocklist belongs to
*
* @returns {Promise<APIResponse>} The server response
*/
updateBlockList(name: string, data: { words: string[]; team?: string }) {
return this.put<APIResponse>(`${this.baseURL}/blocklists/${encodeURIComponent(name)}`, data);
}

deleteBlockList(name: string) {
return this.delete<APIResponse>(`${this.baseURL}/blocklists/${encodeURIComponent(name)}`);
/**
* Deletes a block list
*
* @param {string} name - The name of the block list to delete
* @param {Object} [data] - Query parameters
* @param {string} [data.team] - Team ID that blocklist belongs to
*
* @returns {Promise<APIResponse>} The server response
*/
deleteBlockList(name: string, data?: { team?: string }) {
return this.delete<APIResponse>(`${this.baseURL}/blocklists/${encodeURIComponent(name)}`, data);
}

exportChannels(request: Array<ExportChannelRequest>, options: ExportChannelOptions = {}) {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,7 @@ export type OGAttachment = {
export type BlockList = {
name: string;
words: string[];
team?: string;
type?: string;
validate?: boolean;
};
Expand Down