Skip to content

Commit 0c96e70

Browse files
authored
feat: add hide_history_before option for adding members (#208)
1 parent a3a32a1 commit 0c96e70

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

stream_chat/async_chat/channel.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import datetime
12
import json
23
from typing import Any, Dict, Iterable, List, Optional, Union
34

@@ -94,6 +95,10 @@ async def add_members(
9495
self, members: Iterable[Dict], message: Dict = None, **options: Any
9596
) -> StreamResponse:
9697
payload = {"add_members": members, "message": message, **options}
98+
if "hide_history_before" in payload and isinstance(
99+
payload["hide_history_before"], datetime.datetime
100+
):
101+
payload["hide_history_before"] = payload["hide_history_before"].isoformat()
97102
return await self.client.post(self.url, data=payload)
98103

99104
async def assign_roles(

stream_chat/base/channel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def add_members(
196196
197197
:param members: member objects to add
198198
:param message: An optional to show
199-
:param options: additional options such as hide_history
199+
:param options: additional options such as hide_history or hide_history_before
200200
:return:
201201
"""
202202
pass

stream_chat/channel.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import datetime
12
import json
23
from typing import Any, Dict, Iterable, List, Optional, Union
34

@@ -95,6 +96,10 @@ def add_members(
9596
**options: Any,
9697
) -> StreamResponse:
9798
payload = {"add_members": members, "message": message, **options}
99+
if "hide_history_before" in payload and isinstance(
100+
payload["hide_history_before"], datetime.datetime
101+
):
102+
payload["hide_history_before"] = payload["hide_history_before"].isoformat()
98103
return self.client.post(self.url, data=payload)
99104

100105
def assign_roles(

0 commit comments

Comments
 (0)