|
14 | 14 | from getstream.common.async_client import CommonClient as AsyncCommonClient |
15 | 15 | from getstream.common.client import CommonClient |
16 | 16 | from getstream.feeds.client import FeedsClient |
17 | | -from getstream.models import UserRequest |
| 17 | +from getstream.models import FullUserResponse, UserRequest |
18 | 18 | from getstream.moderation.client import ModerationClient |
19 | 19 | from getstream.moderation.async_client import ModerationClient as AsyncModerationClient |
20 | 20 | from getstream.utils import validate_and_clean_url |
@@ -212,13 +212,16 @@ def feeds(self): |
212 | 212 | raise NotImplementedError("Feeds not supported for async client") |
213 | 213 |
|
214 | 214 | @telemetry.operation_name("getstream.api.common.create_user") |
215 | | - async def create_user(self, name: str = "", id: str = str(uuid4()), image=""): |
| 215 | + async def create_user( |
| 216 | + self, name: str = "", id: str = "", image: str = "" |
| 217 | + ) -> FullUserResponse: |
216 | 218 | """ |
217 | 219 | Creates or updates users. This method performs an "upsert" operation, |
218 | 220 | where it checks if each user already exists and updates their information |
219 | 221 | if they do, or creates a new user entry if they do not. |
220 | 222 | """ |
221 | | - user = UserRequest(name=name, id=id) |
| 223 | + id = id or str(uuid4()) |
| 224 | + user = UserRequest(name=name, id=id, image=image) |
222 | 225 | users_map = {user.id: user} |
223 | 226 | response = await self.update_users(users_map) |
224 | 227 | user = response.data.users[user.id] |
@@ -328,13 +331,16 @@ def feeds(self) -> FeedsClient: |
328 | 331 | ) |
329 | 332 |
|
330 | 333 | @telemetry.operation_name("getstream.api.common.create_user") |
331 | | - def create_user(self, name: str = "", id: str = str(uuid4()), image=""): |
| 334 | + def create_user( |
| 335 | + self, name: str = "", id: str = "", image: str = "" |
| 336 | + ) -> FullUserResponse: |
332 | 337 | """ |
333 | 338 | Creates or updates users. This method performs an "upsert" operation, |
334 | 339 | where it checks if each user already exists and updates their information |
335 | 340 | if they do, or creates a new user entry if they do not. |
336 | 341 | """ |
337 | | - user = UserRequest(name=name, id=id) |
| 342 | + id = id or str(uuid4()) |
| 343 | + user = UserRequest(name=name, id=id, image=image) |
338 | 344 | users_map = {user.id: user} |
339 | 345 | response = self.update_users(users_map) |
340 | 346 | user = response.data.users[user.id] |
|
0 commit comments