Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add type field support on create_blocklist() #149

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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