Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add get_userinfo_by_id method to ModuleApi #9581

Merged
merged 17 commits into from
Aug 4, 2021
Merged
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions synapse/storage/databases/main/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,17 @@ async def get_userinfo_by_id(self, user_id: str) -> Optional[UserInfo]:
desc="get_userinfo_by_id",
)
if not user_data:
return
return None
return UserInfo(
appservice_id=user_data.get("appservice_id"),
consent_server_notice_sent=user_data.get("consent_server_notice_sent"),
consent_version=user_data.get("consent_version"),
creation_ts=user_data.get("creation_ts"),
creation_ts=user_data.get("creation_ts", 0),
is_admin=bool(user_data.get("admin")),
is_deactivated=bool(user_data.get("deactivated")),
is_guest=bool(user_data.get("is_guest")),
is_shadow_banned=bool(user_data.get("shadow_banned")),
user_id=UserID.from_string(user_data.get("name")),
user_id=UserID.from_string(str(user_data.get("name"))),
user_type=user_data.get("user_type"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixes seem a bit hacky just to fix the type checks, as the return types are Any from the selects.

It's because you're using user_data.get. .get returns None if the dict doesn't contain that property. In this case, we know that the dict will contain each of these properties, so you should do user_data["appservice_id"] instead, which I think will also keep mypy happy.

)

Expand Down