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

Commit

Permalink
Return a single dictionary of all results.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Mar 24, 2023
1 parent ae45b94 commit 18e8736
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions synapse/handlers/appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Dict,
Iterable,
List,
Mapping,
Optional,
Tuple,
Union,
Expand Down Expand Up @@ -901,8 +902,8 @@ async def claim_e2e_one_time_keys(
return claimed_keys, missing

async def query_keys(
self, query: Dict[str, Optional[ List[str]]]
) -> Iterable[Dict[str, Dict[str, Dict[str, JsonDict]]]]:
self, query: Mapping[str, Optional[List[str]]]
) -> Dict[str, Dict[str, Dict[str, JsonDict]]]:
"""Query application services for device keys.
Args:
Expand All @@ -922,7 +923,9 @@ async def query_keys(
# Find the associated appservice.
for service in services:
if service.is_exclusive_user(user_id):
query_by_appservice.setdefault(service.id, {})[user_id] = device_ids
query_by_appservice.setdefault(service.id, {})[user_id] = (
device_ids or []
)
continue

# Query each service in parallel.
Expand All @@ -941,10 +944,11 @@ async def query_keys(
)
)

# Patch together the results.
key_queries: List[Dict[str, Dict[str, Dict[str, JsonDict]]]] = []
# Patch together the results. Since the appservices are exclusive they
# can just be splatted together.
key_queries: Dict[str, Dict[str, Dict[str, JsonDict]]] = {}
for success, result in results:
if success:
key_queries.append(result)
key_queries.update(result)

return key_queries

0 comments on commit 18e8736

Please sign in to comment.