Skip to content

Commit

Permalink
feat: add type support in create_blocklist() payload
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorapo808 committed Nov 14, 2023
1 parent d9a2122 commit 62982e3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions stream_chat/async_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ async def send_file(
) as response:
return await self._parse_response(response)

async def create_blocklist(self, name: str, words: Iterable[str]) -> StreamResponse:
return await self.post("blocklists", data={"name": name, "words": words})
async def create_blocklist(self, name: str, words: Iterable[str], blocklist_type: str = None) -> StreamResponse:
return await self.post("blocklists", data={"name": name, "words": words, "type": blocklist_type})

async def list_blocklists(self) -> StreamResponse:
return await self.get("blocklists")
Expand Down
3 changes: 2 additions & 1 deletion stream_chat/base/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,13 +753,14 @@ def send_file(

@abc.abstractmethod
def create_blocklist(
self, name: str, words: Iterable[str]
self, name: str, words: Iterable[str], blocklist_type: str = None
) -> Union[StreamResponse, Awaitable[StreamResponse]]:
"""
Create a blocklist
:param name: the name of the blocklist
:param words: list of blocked words
:param blocklist_type: blocklist type
:return:
"""
pass
Expand Down
4 changes: 2 additions & 2 deletions stream_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ def send_file(
)
return self._parse_response(response)

def create_blocklist(self, name: str, words: Iterable[str]) -> StreamResponse:
return self.post("blocklists", data={"name": name, "words": words})
def create_blocklist(self, name: str, words: Iterable[str], blocklist_type: str = None) -> StreamResponse:
return self.post("blocklists", data={"name": name, "words": words, "type": blocklist_type})

def list_blocklists(self) -> StreamResponse:
return self.get("blocklists")
Expand Down
2 changes: 1 addition & 1 deletion stream_chat/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ def test_query_channels_members_in(
assert len(response["channels"][0]["members"]) == 9

def test_create_blocklist(self, client: StreamChat):
client.create_blocklist(name="Foo", words=["fudge", "heck"])
client.create_blocklist(name="Foo", words=["fudge", "heck"], blocklist_type="regular")

def test_list_blocklists(self, client: StreamChat):
response = client.list_blocklists()
Expand Down

0 comments on commit 62982e3

Please sign in to comment.