Skip to content

Commit 4101531

Browse files
authored
feat: add filter tags to channels (#1646)
Linear ticket: https://linear.app/stream/issue/CHA-1465/js ## CLA - [ ] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required). - [ ] Code changes are tested ## Description of the changes, What, Why and How? ## Changelog -
1 parent d04fade commit 4101531

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

src/channel.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,38 @@ export class Channel {
775775
return await this._update({ add_members: members, message, ...options });
776776
}
777777

778+
/**
779+
* addFilterTags - add filter tags to the channel
780+
*
781+
* @param {string[]} tags An array of tags to add to the channel
782+
* @param {Message} [message] Optional message object for channel members notification
783+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
784+
* @return {Promise<UpdateChannelAPIResponse>} The server response
785+
*/
786+
async addFilterTags(
787+
tags: string[],
788+
message?: Message,
789+
options: ChannelUpdateOptions = {},
790+
) {
791+
return await this._update({ add_filter_tags: tags, message, ...options });
792+
}
793+
794+
/**
795+
* removeFilterTags - remove filter tags from the channel
796+
*
797+
* @param {string[]} tags An array of tags to remove from the channel
798+
* @param {Message} [message] Optional message object for channel members notification
799+
* @param {ChannelUpdateOptions} [options] Option object, configuration to control the behavior while updating
800+
* @return {Promise<UpdateChannelAPIResponse>} The server response
801+
*/
802+
async removeFilterTags(
803+
tags: string[],
804+
message?: Message,
805+
options: ChannelUpdateOptions = {},
806+
) {
807+
return await this._update({ remove_filter_tags: tags, message, ...options });
808+
}
809+
778810
/**
779811
* addModerators - add moderators to the channel
780812
*

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ export type ChannelResponse = CustomChannelData & {
282282
created_by?: UserResponse | null;
283283
created_by_id?: string;
284284
deleted_at?: string;
285+
filter_tags?: string[];
285286
hidden?: boolean;
286287
invites?: string[];
287288
joined?: boolean;
@@ -2425,6 +2426,7 @@ export type ChannelData = CustomChannelData &
24252426
members: string[] | Array<NewMemberPayload>;
24262427
blocklist_behavior: AutomodBehavior;
24272428
automod: Automod;
2429+
filter_tags: string[];
24282430
}>;
24292431

24302432
export type ChannelMute = {

test/typescript/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ const executables = [
2222
imports: ['Channel', 'Unpacked'],
2323
type: "Unpacked<ReturnType<Channel<{ attachmentType: {}; channelType: { description?: string; }; commandType: string & {}; eventType: {}; messageType: {}; reactionType: {}; userType: {}; pollType: {}; pollOptionType: {}; }>['addMembers']>>",
2424
},
25+
{
26+
f: rg.addFilterTags,
27+
imports: ['Channel', 'Unpacked'],
28+
type: "Unpacked<ReturnType<Channel<{ attachmentType: {}; channelType: { description?: string; }; commandType: string & {}; eventType: {}; messageType: {}; reactionType: {}; userType: {}; pollType: {}; pollOptionType: {}; }>['addFilterTags']>>",
29+
},
2530
{
2631
f: rg.addModerators,
2732
imports: ['Channel', 'Unpacked'],
@@ -333,6 +338,11 @@ const executables = [
333338
imports: ['Channel', 'Unpacked'],
334339
type: "Unpacked<ReturnType<Channel<{ attachmentType: {}; channelType: { description?: string; }; commandType: string & {}; eventType: {}; messageType: {}; reactionType: {}; userType: {}; pollType: {}; pollOptionType: {}; }>['removeMembers']>>",
335340
},
341+
{
342+
f: rg.removeFilterTags,
343+
imports: ['Channel', 'Unpacked'],
344+
type: "Unpacked<ReturnType<Channel<{ attachmentType: {}; channelType: { description?: string; }; commandType: string & {}; eventType: {}; messageType: {}; reactionType: {}; userType: {}; pollType: {}; pollOptionType: {}; }>['removeFilterTags']>>",
345+
},
336346
{
337347
f: rg.removeShadowBan,
338348
imports: ['StreamChat', 'DefaultGenerics', 'Unpacked'],

test/typescript/response-generators/channel.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ async function addMembers() {
2727
return await channel.addMembers(newMembers);
2828
}
2929

30+
async function addFilterTags() {
31+
const channel = await utils.createTestChannelForUser(uuidv4(), johnID);
32+
await channel.watch();
33+
34+
return await channel.addFilterTags(['tag1', 'tag2']);
35+
}
36+
37+
async function removeFilterTags() {
38+
const channel = await utils.createTestChannelForUser(uuidv4(), johnID);
39+
await channel.watch();
40+
41+
return await channel.removeFilterTags(['tag1']);
42+
}
43+
3044
async function addModerators() {
3145
const channel = await utils.createTestChannel(uuidv4(), johnID);
3246
return await channel.addModerators([johnID]);
@@ -243,6 +257,7 @@ async function watch() {
243257
module.exports = {
244258
acceptInvite,
245259
addMembers,
260+
addFilterTags,
246261
addModerators,
247262
create,
248263
deleteChannel,
@@ -260,6 +275,7 @@ module.exports = {
260275
queryMembers,
261276
rejectInvite,
262277
removeMembers,
278+
removeFilterTags,
263279
sendFile,
264280
sendImage,
265281
show,

0 commit comments

Comments
 (0)