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

[CHAT-1823] Add async deleteChannels endpoint #769

Merged
merged 5 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
19 changes: 19 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,22 @@ 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 {hard_delete?: boolean} hard_delete Defines if the channel is hard deleted or not
mahboubii marked this conversation as resolved.
Show resolved Hide resolved
*
* @return {TaskResponse} A task ID
*/
async deleteChannels(cids: string[], hard_delete?: boolean) {
yaziine marked this conversation as resolved.
Show resolved Hide resolved
return await this.post<APIResponse & TaskResponse>(
this.baseURL + `/channels/delete`,
{
cids,
hard_delete,
mahboubii marked this conversation as resolved.
Show resolved Hide resolved
},
);
}
}
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