Skip to content

Commit 2effaba

Browse files
feat: add Future Channel Bans support [CHA-1696] (#1677)
## Summary Add support for the Future Channel Bans feature. ### New Parameters - `ban_from_future_channels` parameter in `channel.banUser()` options - `remove_future_channels_ban` parameter in `client.unbanUser()` options ### Usage ```typescript // Ban user from current channel and all future channels created by banner await channel.banUser('user-id', { ban_from_future_channels: true, reason: 'spam', }); // Remove future channel ban (does NOT remove existing channel bans) await client.unbanUser('user-id', { channel_cid: 'messaging:channel-id', created_by: 'banner-user-id', remove_future_channels_ban: true, }); // Query future channel bans const response = await client.queryFutureChannelBans({ created_by_id: 'banner-user-id', }); ``` ## Related PRs - Backend: GetStream/chat#11390 ## Linear - CHA-1696 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent cb6d2d1 commit 2effaba

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

src/channel.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import type {
6969
StaticLocationPayload,
7070
TruncateChannelAPIResponse,
7171
TruncateOptions,
72+
UnBanUserOptions,
7273
UpdateChannelAPIResponse,
7374
UpdateChannelOptions,
7475
UpdateLocationPayload,
@@ -1659,11 +1660,13 @@ export class Channel {
16591660
* unbanUser - Removes the bans for a user on a channel
16601661
*
16611662
* @param {string} targetUserID
1663+
* @param {UnBanUserOptions} options
16621664
* @returns {Promise<APIResponse>}
16631665
*/
1664-
async unbanUser(targetUserID: string) {
1666+
async unbanUser(targetUserID: string, options?: UnBanUserOptions) {
16651667
this._checkInitialized();
16661668
return await this.getClient().unbanUser(targetUserID, {
1669+
...options,
16671670
type: this.type,
16681671
id: this.id,
16691672
});

src/client.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ import type {
106106
FlagsPaginationOptions,
107107
FlagsResponse,
108108
FlagUserResponse,
109+
FutureChannelBansResponse,
109110
GetBlockedUsersAPIResponse,
110111
GetCampaignOptions,
111112
GetChannelTypeResponse,
@@ -166,6 +167,7 @@ import type {
166167
PushProviderUpsertResponse,
167168
QueryChannelsAPIResponse,
168169
QueryDraftsResponse,
170+
QueryFutureChannelBansOptions,
169171
QueryMessageHistoryFilters,
170172
QueryMessageHistoryOptions,
171173
QueryMessageHistoryResponse,
@@ -1822,6 +1824,21 @@ export class StreamChat {
18221824
});
18231825
}
18241826

1827+
/**
1828+
* queryFutureChannelBans - Query future channel bans created by a user
1829+
*
1830+
* @param {QueryFutureChannelBansOptions} options Option object with user_id, exclude_expired_bans, limit, offset
1831+
* @returns {Promise<FutureChannelBansResponse>} Future Channel Bans Response
1832+
*/
1833+
async queryFutureChannelBans(options: QueryFutureChannelBansOptions = {}) {
1834+
return await this.get<FutureChannelBansResponse>(
1835+
this.baseURL + '/query_future_channel_bans',
1836+
{
1837+
payload: options,
1838+
},
1839+
);
1840+
}
1841+
18251842
/**
18261843
* queryMessageFlags - Query message flags
18271844
*

src/types.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,26 @@ export type BannedUsersResponse = APIResponse & {
284284
}>;
285285
};
286286

287+
export type FutureChannelBan = {
288+
user: UserResponse;
289+
expires?: string;
290+
reason?: string;
291+
shadow?: boolean;
292+
created_at: string;
293+
};
294+
295+
export type FutureChannelBansResponse = APIResponse & {
296+
bans: FutureChannelBan[];
297+
};
298+
299+
export type QueryFutureChannelBansOptions = {
300+
user_id?: string;
301+
target_user_id?: string;
302+
exclude_expired_bans?: boolean;
303+
limit?: number;
304+
offset?: number;
305+
};
306+
287307
export type BlockListResponse = BlockList & {
288308
created_at?: string;
289309
type?: string;
@@ -994,6 +1014,7 @@ export type BannedUsersPaginationOptions = Omit<
9941014
};
9951015

9961016
export type BanUserOptions = UnBanUserOptions & {
1017+
ban_from_future_channels?: boolean;
9971018
banned_by?: UserResponse;
9981019
banned_by_id?: string;
9991020
ip_ban?: boolean;
@@ -1493,6 +1514,7 @@ export type UnBanUserOptions = {
14931514
client_id?: string;
14941515
connection_id?: string;
14951516
id?: string;
1517+
remove_future_channels_ban?: boolean;
14961518
shadow?: boolean;
14971519
target_user_id?: string;
14981520
type?: string;

0 commit comments

Comments
 (0)