You've already forked snikket-web-portal
Merge pull request #151 from snikket-im/fix/user-listing-roles
Make AdminUserInfo compatible with new API
This commit is contained in:
@@ -61,12 +61,18 @@ class AdminUserInfo:
|
|||||||
cls,
|
cls,
|
||||||
data: typing.Mapping[str, typing.Any],
|
data: typing.Mapping[str, typing.Any],
|
||||||
) -> "AdminUserInfo":
|
) -> "AdminUserInfo":
|
||||||
|
try:
|
||||||
|
roles: typing.Optional[typing.List[str]] = [data["role"]]
|
||||||
|
assert roles is not None # make mypy happy
|
||||||
|
roles.extend(data.get("secondary_roles", []))
|
||||||
|
except KeyError:
|
||||||
|
roles = data.get("roles")
|
||||||
return cls(
|
return cls(
|
||||||
localpart=data["username"],
|
localpart=data["username"],
|
||||||
display_name=data.get("display_name") or None,
|
display_name=data.get("display_name") or None,
|
||||||
email=data.get("email") or None,
|
email=data.get("email") or None,
|
||||||
phone=data.get("phone") or None,
|
phone=data.get("phone") or None,
|
||||||
roles=data.get("roles"),
|
roles=roles,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user