Skip to content
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
3 changes: 3 additions & 0 deletions stream_chat/async_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,9 @@ async def export_channels(
async def get_export_channel_status(self, task_id: str) -> StreamResponse:
return await self.get(f"export_channels/{task_id}")

async def export_users(self, user_ids: Iterable[str]) -> StreamResponse:
return await self.post("export/users", data={"user_ids": user_ids})

async def get_task(self, task_id: str) -> StreamResponse:
return await self.get(f"tasks/{task_id}")

Expand Down
9 changes: 9 additions & 0 deletions stream_chat/base/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,15 @@ def get_export_channel_status(
"""
pass

@abc.abstractmethod
def export_users(
self, user_ids: Iterable[str]
) -> Union[StreamResponse, Awaitable[StreamResponse]]:
"""
Requests a users export
"""
pass

@abc.abstractmethod
def get_task(
self, task_id: str
Expand Down
3 changes: 3 additions & 0 deletions stream_chat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,9 @@ def export_channels(
def get_export_channel_status(self, task_id: str) -> StreamResponse:
return self.get(f"export_channels/{task_id}")

def export_users(self, user_ids: Iterable[str]) -> StreamResponse:
return self.post("export/users", data={"user_ids": user_ids})

def get_task(self, task_id: str) -> StreamResponse:
return self.get(f"tasks/{task_id}")

Expand Down
1 change: 0 additions & 1 deletion stream_chat/tests/async_chat/test_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ async def test_send_message_with_options(self, channel: Channel, random_user: Di
async def test_send_message_with_restricted_visibility(
self, client: StreamChatAsync, channel: Channel, random_user: Dict
):

# Create test users first
restricted_users = [
{"id": "amy", "name": "Amy"},
Expand Down
17 changes: 17 additions & 0 deletions stream_chat/tests/async_chat/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,23 @@ async def test_export_user(self, client: StreamChatAsync, fellowship_of_the_ring
assert "user" in response
assert response["user"]["name"] == "Gandalf the Grey"

async def test_export_users(self, client: StreamChatAsync, random_user: Dict):
response = await client.export_users([random_user["id"]])
assert "task_id" in response
assert len(response["task_id"]) == 36

async def f():
r = await client.get_task(response["task_id"])
return r["status"] == "completed"

await wait_for_async(f)

response = await client.get_task(response["task_id"])
assert response["status"] == "completed"
assert "result" in response
assert "url" in response["result"]
assert "/exports/users/" in response["result"]["url"]

async def test_ban_user(
self, client: StreamChatAsync, random_user, server_user: Dict
):
Expand Down
1 change: 0 additions & 1 deletion stream_chat/tests/test_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def test_send_pending_message(
def test_send_message_with_restricted_visibility(
self, client: StreamChat, channel: Channel, random_user: Dict
):

# Create test users first
restricted_users = [
{"id": "amy", "name": "Amy"},
Expand Down
13 changes: 13 additions & 0 deletions stream_chat/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,19 @@ def test_export_user(self, client: StreamChat, fellowship_of_the_ring):
assert "user" in response
assert response["user"]["name"] == "Gandalf the Grey"

def test_export_users(self, client: StreamChat, random_user: Dict):
response = client.export_users([random_user["id"]])
assert "task_id" in response
assert len(response["task_id"]) == 36

wait_for(lambda: client.get_task(response["task_id"])["status"] == "completed")

response = client.get_task(response["task_id"])
assert response["status"] == "completed"
assert "result" in response
assert "url" in response["result"]
assert "/exports/users/" in response["result"]["url"]

def test_shadow_ban(
self, client: StreamChat, random_user, server_user, channel: Channel
):
Expand Down