Skip to content

Commit 786a50c

Browse files
authored
feat: Add type field support on create_blocklist() (#149)
* feat: add type support in create_blocklist() payload * feat: fix linters * feat: rename param to type in payload * change to explicit regular type as default
1 parent d9a2122 commit 786a50c

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

stream_chat/async_chat/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,12 @@ async def send_file(
472472
) as response:
473473
return await self._parse_response(response)
474474

475-
async def create_blocklist(self, name: str, words: Iterable[str]) -> StreamResponse:
476-
return await self.post("blocklists", data={"name": name, "words": words})
475+
async def create_blocklist(
476+
self, name: str, words: Iterable[str], type: str = "regular"
477+
) -> StreamResponse:
478+
return await self.post(
479+
"blocklists", data={"name": name, "words": words, "type": type}
480+
)
477481

478482
async def list_blocklists(self) -> StreamResponse:
479483
return await self.get("blocklists")

stream_chat/base/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,13 +753,14 @@ def send_file(
753753

754754
@abc.abstractmethod
755755
def create_blocklist(
756-
self, name: str, words: Iterable[str]
756+
self, name: str, words: Iterable[str], type: str = "regular"
757757
) -> Union[StreamResponse, Awaitable[StreamResponse]]:
758758
"""
759759
Create a blocklist
760760
761761
:param name: the name of the blocklist
762762
:param words: list of blocked words
763+
:param type: blocklist type
763764
:return:
764765
"""
765766
pass

stream_chat/client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,12 @@ def send_file(
456456
)
457457
return self._parse_response(response)
458458

459-
def create_blocklist(self, name: str, words: Iterable[str]) -> StreamResponse:
460-
return self.post("blocklists", data={"name": name, "words": words})
459+
def create_blocklist(
460+
self, name: str, words: Iterable[str], type: str = "regular"
461+
) -> StreamResponse:
462+
return self.post(
463+
"blocklists", data={"name": name, "words": words, "type": type}
464+
)
461465

462466
def list_blocklists(self) -> StreamResponse:
463467
return self.get("blocklists")

stream_chat/tests/test_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ def test_query_channels_members_in(
549549
assert len(response["channels"][0]["members"]) == 9
550550

551551
def test_create_blocklist(self, client: StreamChat):
552-
client.create_blocklist(name="Foo", words=["fudge", "heck"])
552+
client.create_blocklist(name="Foo", words=["fudge", "heck"], type="regular")
553553

554554
def test_list_blocklists(self, client: StreamChat):
555555
response = client.list_blocklists()

0 commit comments

Comments
 (0)