Skip to content

Commit

Permalink
feat: use set serializer for user list in sites
Browse files Browse the repository at this point in the history
  • Loading branch information
martastain committed Oct 24, 2024
1 parent f2501c2 commit f210dbf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/system/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ async def get_user_sites(
# record matches the current site
current_site_exists = True
if user_name not in site.users:
current_site.users.extend(site.users)
current_site.users.update(site.users)
current_needs_update = True
# we can use elif here, because we only need to check one condition
elif site.platform != current_site.platform:
Expand Down
2 changes: 1 addition & 1 deletion api/system/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SiteInfo(OPModel):
platform: Platform = Field(...)
hostname: str = Field(..., title="Machine hostname")
version: str = Field(..., title="Ayon version")
users: list[str] = Field(..., title="List of users")
users: set[str] = Field(..., title="List of users")


@router.get("/system/sites", tags=["System"])
Expand Down
3 changes: 3 additions & 0 deletions ayon_server/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def json_default_handler(value: Any) -> Any:
if isinstance(value, datetime.datetime):
return value.isoformat()

if isinstance(value, set):
return list(value)

raise TypeError(f"Type {type(value)} is not JSON serializable")


Expand Down

0 comments on commit f210dbf

Please sign in to comment.