Skip to content

Commit

Permalink
feat: multitenant blocklist support (#1450)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnarkhede authored Jan 29, 2025
1 parent 243ece9 commit e06d1bb
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
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

0 comments on commit e06d1bb

Please sign in to comment.