Make AdminUserInfo compatible with new API

The mod_http_admin_api changed recently [1], so we need to follow
suit.

Fixes #149.

   [1]: https://hg.prosody.im/prosody-modules/rev/d68348323406
This commit is contained in:
Jonas Schäfer
2023-03-28 22:16:15 +02:00
parent 49bbc3ab09
commit 2762304ae8

View File

@@ -61,12 +61,18 @@ class AdminUserInfo:
cls,
data: typing.Mapping[str, typing.Any],
) -> "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(
localpart=data["username"],
display_name=data.get("display_name") or None,
email=data.get("email") or None,
phone=data.get("phone") or None,
roles=data.get("roles"),
roles=roles,
)