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

Ensure is_verified on /_matrix/client/r0/room_keys/keys is a boolean #7150

Merged
merged 5 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
1 change: 1 addition & 0 deletions changelog.d/7150.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure `is_verified` is a boolean in responses to `GET /_matrix/client/r0/room_keys/keys`. Also warn the user if they forgot the `version` query param.
5 changes: 5 additions & 0 deletions synapse/rest/client/v2_alpha/room_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ async def on_GET(self, request, room_id, session_id):
user_id = requester.user.to_string()
version = parse_string(request, "version")
Copy link
Member

Choose a reason for hiding this comment

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

I think you can provide the required parameter to parse_string to do the same thing, not 100% sure though.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are correct, good shout!


if not version:
raise SynapseError(
400, "Missing version query parameter", errcode=Codes.MISSING_PARAM
)

room_keys = await self.e2e_room_keys_handler.get_room_keys(
user_id, version, room_id, session_id
)
Expand Down
3 changes: 2 additions & 1 deletion synapse/storage/data_stores/main/e2e_room_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ def get_e2e_room_keys(self, user_id, version, room_id=None, session_id=None):
room_entry["sessions"][row["session_id"]] = {
"first_message_index": row["first_message_index"],
"forwarded_count": row["forwarded_count"],
"is_verified": row["is_verified"],
# is_verified must be returned to the client as a boolean
"is_verified": bool(row["is_verified"]),
"session_data": json.loads(row["session_data"]),
}

Expand Down