Skip to content

Commit 82f07ff

Browse files
authored
feat: add options to export channel (#100)
1 parent 2f8f22a commit 82f07ff

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

stream_chat/async_chat/client.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ async def export_channel(
552552
channel_id: str,
553553
messages_since: Union[str, datetime.datetime] = None,
554554
messages_until: Union[str, datetime.datetime] = None,
555+
**options: Any,
555556
) -> StreamResponse:
556557
if isinstance(messages_since, datetime.datetime):
557558
messages_since = messages_since.isoformat()
@@ -566,11 +567,16 @@ async def export_channel(
566567
"messages_since": messages_since,
567568
"messages_until": messages_until,
568569
}
569-
]
570+
],
571+
**options,
570572
)
571573

572-
async def export_channels(self, channels: Iterable[Dict]) -> StreamResponse:
573-
return await self.post("export_channels", data={"channels": channels})
574+
async def export_channels(
575+
self, channels: Iterable[Dict], **options: Any
576+
) -> StreamResponse:
577+
return await self.post(
578+
"export_channels", data={"channels": channels, **options}
579+
)
574580

575581
async def get_export_channel_status(self, task_id: str) -> StreamResponse:
576582
return await self.get(f"export_channels/{task_id}")

stream_chat/base/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ def export_channel(
823823
channel_id: str,
824824
messages_since: Union[str, datetime.datetime] = None,
825825
messages_until: Union[str, datetime.datetime] = None,
826+
**options: Any,
826827
) -> Union[StreamResponse, Awaitable[StreamResponse]]:
827828
"""
828829
Requests a channel export
@@ -831,7 +832,7 @@ def export_channel(
831832

832833
@abc.abstractmethod
833834
def export_channels(
834-
self, channels: Iterable[Dict]
835+
self, channels: Iterable[Dict], **options: Any
835836
) -> Union[StreamResponse, Awaitable[StreamResponse]]:
836837
"""
837838
Requests a channels export

stream_chat/client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ def export_channel(
524524
channel_id: str,
525525
messages_since: Union[str, datetime.datetime] = None,
526526
messages_until: Union[str, datetime.datetime] = None,
527+
**options: Any,
527528
) -> StreamResponse:
528529
if isinstance(messages_since, datetime.datetime):
529530
messages_since = messages_since.isoformat()
@@ -538,11 +539,14 @@ def export_channel(
538539
"messages_since": messages_since,
539540
"messages_until": messages_until,
540541
}
541-
]
542+
],
543+
**options,
542544
)
543545

544-
def export_channels(self, channels: Iterable[Dict]) -> StreamResponse:
545-
return self.post("export_channels", data={"channels": channels})
546+
def export_channels(
547+
self, channels: Iterable[Dict], **options: Any
548+
) -> StreamResponse:
549+
return self.post("export_channels", data={"channels": channels, **options})
546550

547551
def get_export_channel_status(self, task_id: str) -> StreamResponse:
548552
return self.get(f"export_channels/{task_id}")

stream_chat/tests/async_chat/test_channel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ async def test_export_channel(
340340
):
341341
await channel.send_message({"text": "Hey Joni"}, random_users[0]["id"])
342342

343-
resp = await client.export_channel(channel.channel_type, channel.id)
343+
resp = await client.export_channel(
344+
channel.channel_type, channel.id, include_truncated_messages=False
345+
)
344346
task_id = resp["task_id"]
345347
assert task_id != ""
346348

stream_chat/tests/test_channel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,9 @@ def test_export_channel(
328328
):
329329
channel.send_message({"text": "Hey Joni"}, random_users[0]["id"])
330330

331-
resp = client.export_channel(channel.channel_type, channel.id)
331+
resp = client.export_channel(
332+
channel.channel_type, channel.id, include_truncated_messages=False
333+
)
332334
task_id = resp["task_id"]
333335
assert task_id != ""
334336

0 commit comments

Comments
 (0)