1414# limitations under the License.
1515
1616import logging
17- from typing import TYPE_CHECKING , List , Optional
17+ from typing import TYPE_CHECKING , Dict , Optional
18+
19+ from typing_extensions import Literal
1820
1921from synapse .api .errors import (
2022 Codes ,
2426 SynapseError ,
2527)
2628from synapse .logging .opentracing import log_kv , trace
29+ from synapse .storage .databases .main .e2e_room_keys import RoomKey
2730from synapse .types import JsonDict
2831from synapse .util .async_helpers import Linearizer
2932
@@ -58,7 +61,9 @@ async def get_room_keys(
5861 version : str ,
5962 room_id : Optional [str ] = None ,
6063 session_id : Optional [str ] = None ,
61- ) -> List [JsonDict ]:
64+ ) -> Dict [
65+ Literal ["rooms" ], Dict [str , Dict [Literal ["sessions" ], Dict [str , RoomKey ]]]
66+ ]:
6267 """Bulk get the E2E room keys for a given backup, optionally filtered to a given
6368 room, or a given session.
6469 See EndToEndRoomKeyStore.get_e2e_room_keys for full details.
@@ -72,8 +77,8 @@ async def get_room_keys(
7277 Raises:
7378 NotFoundError: if the backup version does not exist
7479 Returns:
75- A list of dicts giving the session_data and message metadata for
76- these room keys.
80+ A dict giving the session_data and message metadata for these room keys.
81+ `{"rooms": {room_id: {"sessions": {session_id: room_key}}}}`
7782 """
7883
7984 # we deliberately take the lock to get keys so that changing the version
@@ -273,7 +278,7 @@ async def upload_room_keys(
273278
274279 @staticmethod
275280 def _should_replace_room_key (
276- current_room_key : Optional [JsonDict ], room_key : JsonDict
281+ current_room_key : Optional [RoomKey ], room_key : RoomKey
277282 ) -> bool :
278283 """
279284 Determine whether to replace a given current_room_key (if any)
0 commit comments