diff --git a/stream_chat/async_chat/channel.py b/stream_chat/async_chat/channel.py index a66fb7f..c8023ea 100644 --- a/stream_chat/async_chat/channel.py +++ b/stream_chat/async_chat/channel.py @@ -1,3 +1,4 @@ +import datetime import json from typing import Any, Dict, Iterable, List, Optional, Union @@ -94,6 +95,10 @@ async def add_members( self, members: Iterable[Dict], message: Dict = None, **options: Any ) -> StreamResponse: payload = {"add_members": members, "message": message, **options} + if "hide_history_before" in payload and isinstance( + payload["hide_history_before"], datetime.datetime + ): + payload["hide_history_before"] = payload["hide_history_before"].isoformat() return await self.client.post(self.url, data=payload) async def assign_roles( diff --git a/stream_chat/base/channel.py b/stream_chat/base/channel.py index 8e300a5..d49a3f7 100644 --- a/stream_chat/base/channel.py +++ b/stream_chat/base/channel.py @@ -196,7 +196,7 @@ def add_members( :param members: member objects to add :param message: An optional to show - :param options: additional options such as hide_history + :param options: additional options such as hide_history or hide_history_before :return: """ pass diff --git a/stream_chat/channel.py b/stream_chat/channel.py index 2373811..f5ce5c7 100644 --- a/stream_chat/channel.py +++ b/stream_chat/channel.py @@ -1,3 +1,4 @@ +import datetime import json from typing import Any, Dict, Iterable, List, Optional, Union @@ -95,6 +96,10 @@ def add_members( **options: Any, ) -> StreamResponse: payload = {"add_members": members, "message": message, **options} + if "hide_history_before" in payload and isinstance( + payload["hide_history_before"], datetime.datetime + ): + payload["hide_history_before"] = payload["hide_history_before"].isoformat() return self.client.post(self.url, data=payload) def assign_roles(