From 37d67b6af11630aa1e0f8ffc4f35e108ad6eab22 Mon Sep 17 00:00:00 2001 From: javierdfm Date: Fri, 7 Nov 2025 11:41:08 +0100 Subject: [PATCH 1/3] feat: add filter tags support for channels --- stream_chat/async_chat/channel.py | 16 ++++++++++++++++ stream_chat/base/channel.py | 26 ++++++++++++++++++++++++++ stream_chat/channel.py | 16 ++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/stream_chat/async_chat/channel.py b/stream_chat/async_chat/channel.py index c8023ea..0f0fcf7 100644 --- a/stream_chat/async_chat/channel.py +++ b/stream_chat/async_chat/channel.py @@ -272,3 +272,19 @@ async def get_draft( if parent_id: params["parent_id"] = parent_id return await self.client.get(f"{self.url}/draft", params=params) + + async def add_filter_tags( + self, + tags: Iterable[str], + message: Dict = None, + ) -> StreamResponse: + payload = {"add_filter_tags": tags, "message": message} + return await self.client.post(self.url, data=payload) + + async def remove_filter_tags( + self, + tags: Iterable[str], + message: Dict = None, + ) -> StreamResponse: + payload = {"remove_filter_tags": tags, "message": message} + return await self.client.post(self.url, data=payload) diff --git a/stream_chat/base/channel.py b/stream_chat/base/channel.py index d49a3f7..0e14f10 100644 --- a/stream_chat/base/channel.py +++ b/stream_chat/base/channel.py @@ -527,6 +527,32 @@ def get_draft( """ pass + @abc.abstractmethod + def add_filter_tags( + self, tags: Iterable[str], message: Dict = None + ) -> Union[StreamResponse, Awaitable[StreamResponse]]: + """ + Adds filter tags to the channel + + :param tags: list of tags to add + :param message: optional system message + :return: The server response + """ + pass + + @abc.abstractmethod + def remove_filter_tags( + self, tags: Iterable[str], message: Dict = None + ) -> Union[StreamResponse, Awaitable[StreamResponse]]: + """ + Removes filter tags from the channel + + :param tags: list of tags to remove + :param message: optional system message + :return: The server response + """ + pass + def add_user_id(payload: Dict, user_id: str) -> Dict: return {**payload, "user": {"id": user_id}} diff --git a/stream_chat/channel.py b/stream_chat/channel.py index f5ce5c7..b3400b4 100644 --- a/stream_chat/channel.py +++ b/stream_chat/channel.py @@ -276,3 +276,19 @@ def get_draft( params["parent_id"] = parent_id return self.client.get(f"{self.url}/draft", params=params) + + def add_filter_tags( + self, + tags: Iterable[str], + message: Dict = None, + ) -> StreamResponse: + payload = {"add_filter_tags": tags, "message": message} + return self.client.post(self.url, data=payload) + + def remove_filter_tags( + self, + tags: Iterable[str], + message: Dict = None, + ) -> StreamResponse: + payload = {"remove_filter_tags": tags, "message": message} + return self.client.post(self.url, data=payload) From 72c23315b6ba3d9f21d9e1ba274698fd33cc9531 Mon Sep 17 00:00:00 2001 From: javierdfm Date: Fri, 7 Nov 2025 11:41:26 +0100 Subject: [PATCH 2/3] feat: add filter tags support for channels --- stream_chat/tests/test_filter_tags.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 stream_chat/tests/test_filter_tags.py diff --git a/stream_chat/tests/test_filter_tags.py b/stream_chat/tests/test_filter_tags.py new file mode 100644 index 0000000..c770d33 --- /dev/null +++ b/stream_chat/tests/test_filter_tags.py @@ -0,0 +1,20 @@ +import pytest +from typing import Dict, List + +from stream_chat.channel import Channel + + +@pytest.mark.incremental +class TestFilterTags: + def test_add_and_remove_filter_tags(self, channel: Channel): + # Add tags + add_resp = channel.add_filter_tags(["vip", "premium"]) + assert "channel" in add_resp + assert set(add_resp["channel"].get("filter_tags", [])) >= {"vip", "premium"} + + # Remove one tag + remove_resp = channel.remove_filter_tags(["premium"]) + assert "channel" in remove_resp + remaining = remove_resp["channel"].get("filter_tags", []) + assert "premium" not in remaining + assert "vip" in remaining From 02727fb75eb840f15204710901a4d0530a75222b Mon Sep 17 00:00:00 2001 From: javierdfm Date: Fri, 7 Nov 2025 11:47:43 +0100 Subject: [PATCH 3/3] Lint --- stream_chat/tests/test_filter_tags.py | 1 - 1 file changed, 1 deletion(-) diff --git a/stream_chat/tests/test_filter_tags.py b/stream_chat/tests/test_filter_tags.py index c770d33..d7da4f7 100644 --- a/stream_chat/tests/test_filter_tags.py +++ b/stream_chat/tests/test_filter_tags.py @@ -1,5 +1,4 @@ import pytest -from typing import Dict, List from stream_chat.channel import Channel