Skip to content

Commit

Permalink
feat: Add type field support on create_blocklist() (#149)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
viktorapo808 authored Nov 23, 2023
1 parent d9a2122 commit 786a50c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
8 changes: 6 additions & 2 deletions stream_chat/async_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,12 @@ 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], type: str = "regular"
) -> StreamResponse:
return await self.post(
"blocklists", data={"name": name, "words": words, "type": 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], type: str = "regular"
) -> Union[StreamResponse, Awaitable[StreamResponse]]:
"""
Create a blocklist
:param name: the name of the blocklist
:param words: list of blocked words
:param type: blocklist type
:return:
"""
pass
Expand Down
8 changes: 6 additions & 2 deletions stream_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,12 @@ 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], type: str = "regular"
) -> StreamResponse:
return self.post(
"blocklists", data={"name": name, "words": words, "type": 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"], type="regular")

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

0 comments on commit 786a50c

Please sign in to comment.