Skip to content

Commit

Permalink
[CHAT-1823] Add async deleteChannels endpoint (#769)
Browse files Browse the repository at this point in the history
Co-authored-by: Amin Mahboubi <amin@getstream.io>
Co-authored-by: Amin Mahboubi <aminmahboobi@gmail.com>
  • Loading branch information
3 people authored Oct 6, 2021
1 parent 03a0116 commit 668b3e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import {
CampaignData,
OGAttachment,
TaskStatus,
TaskResponse,
} from './types';

function isString(x: unknown): x is string {
Expand Down Expand Up @@ -3305,4 +3306,19 @@ export class StreamChat<
async getTask(id: string) {
return this.get<APIResponse & TaskStatus>(`${this.baseURL}/tasks/${id}`);
}

/**
* deleteChannels - Deletes a list of channel
*
* @param {string[]} cids Channel CIDs
* @param {boolean} [options.hard_delete] Defines if the channel is hard deleted or not
*
* @return {TaskResponse} A task ID
*/
async deleteChannels(cids: string[], options: { hard_delete?: boolean } = {}) {
return await this.post<APIResponse & TaskResponse>(
this.baseURL + `/channels/delete`,
{ cids, ...options },
);
}
}
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2122,6 +2122,10 @@ export type User<UserType = UnknownType> = UserType & {
username?: string;
};

export type TaskResponse = {
task_id: string;
};

export type SegmentData = {
description: string;
// TODO: define this type in more detail
Expand Down

0 comments on commit 668b3e5

Please sign in to comment.