|
15 | 15 | # See the License for the specific language governing permissions and |
16 | 16 | # limitations under the License. |
17 | 17 | import logging |
18 | | -from typing import Any, Callable, Dict, List, Match, Optional, Tuple |
| 18 | +from typing import Any, Callable, Dict, List, Match, Optional, Tuple, Union |
19 | 19 |
|
20 | 20 | import six |
21 | 21 | from six import iteritems |
@@ -111,7 +111,7 @@ async def on_backfill_request( |
111 | 111 | return 200, res |
112 | 112 |
|
113 | 113 | async def on_incoming_transaction( |
114 | | - self, origin: str, transaction_data: Dict[str, Any] |
| 114 | + self, origin: str, transaction_data: JsonDict |
115 | 115 | ) -> Tuple[int, Dict[str, Any]]: |
116 | 116 | # keep this as early as possible to make the calculated origin ts as |
117 | 117 | # accurate as possible. |
@@ -380,7 +380,9 @@ async def _on_context_state_request_compute( |
380 | 380 | "auth_chain": [pdu.get_pdu_json() for pdu in auth_chain], |
381 | 381 | } |
382 | 382 |
|
383 | | - async def on_pdu_request(self, origin: str, event_id: str) -> Tuple[int, str]: |
| 383 | + async def on_pdu_request( |
| 384 | + self, origin: str, event_id: str |
| 385 | + ) -> Tuple[int, Union[JsonDict, str]]: |
384 | 386 | pdu = await self.handler.get_persisted_pdu(origin, event_id) |
385 | 387 |
|
386 | 388 | if pdu: |
@@ -509,7 +511,7 @@ async def on_query_user_devices( |
509 | 511 |
|
510 | 512 | @trace |
511 | 513 | async def on_claim_client_keys( |
512 | | - self, origin: str, content: Dict[str, Any] |
| 514 | + self, origin: str, content: JsonDict |
513 | 515 | ) -> Dict[str, Any]: |
514 | 516 | query = [] |
515 | 517 | for user_id, device_keys in content.get("one_time_keys", {}).items(): |
@@ -577,9 +579,9 @@ async def on_get_missing_events( |
577 | 579 | return {"events": [ev.get_pdu_json(time_now) for ev in missing_events]} |
578 | 580 |
|
579 | 581 | @log_function |
580 | | - def on_openid_userinfo(self, token: str) -> Optional[str]: |
| 582 | + async def on_openid_userinfo(self, token: str) -> Optional[str]: |
581 | 583 | ts_now_ms = self._clock.time_msec() |
582 | | - return self.store.get_user_id_for_open_id_token(token, ts_now_ms) |
| 584 | + return await self.store.get_user_id_for_open_id_token(token, ts_now_ms) |
583 | 585 |
|
584 | 586 | def _transaction_from_pdus(self, pdu_list: List[EventBase]) -> Transaction: |
585 | 587 | """Returns a new Transaction containing the given PDUs suitable for |
|
0 commit comments