diff options
author | Quentin Gliech <quenting@element.io> | 2023-03-07 17:05:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-07 16:05:22 +0000 |
commit | 47bc84dd53b81523d9400af462dcff68185b22fd (patch) | |
tree | 386a263e8fb1e96bddbde66c7cf557b099a124ce /synapse/rest/client/sendtodevice.py | |
parent | Stabilize support for MSC3966: event_property_contains push condition. (#15187) (diff) | |
download | synapse-47bc84dd53b81523d9400af462dcff68185b22fd.tar.xz |
Pass the Requester down to the HttpTransactionCache. (#15200)
Diffstat (limited to 'synapse/rest/client/sendtodevice.py')
-rw-r--r-- | synapse/rest/client/sendtodevice.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/synapse/rest/client/sendtodevice.py b/synapse/rest/client/sendtodevice.py index 55d52f0b28..110af6df47 100644 --- a/synapse/rest/client/sendtodevice.py +++ b/synapse/rest/client/sendtodevice.py @@ -13,7 +13,7 @@ # limitations under the License. import logging -from typing import TYPE_CHECKING, Awaitable, Tuple +from typing import TYPE_CHECKING, Tuple from synapse.http import servlet from synapse.http.server import HttpServer @@ -21,7 +21,7 @@ from synapse.http.servlet import assert_params_in_dict, parse_json_object_from_r from synapse.http.site import SynapseRequest from synapse.logging.opentracing import set_tag from synapse.rest.client.transactions import HttpTransactionCache -from synapse.types import JsonDict +from synapse.types import JsonDict, Requester from ._base import client_patterns @@ -43,19 +43,26 @@ class SendToDeviceRestServlet(servlet.RestServlet): self.txns = HttpTransactionCache(hs) self.device_message_handler = hs.get_device_message_handler() - def on_PUT( + async def on_PUT( self, request: SynapseRequest, message_type: str, txn_id: str - ) -> Awaitable[Tuple[int, JsonDict]]: + ) -> Tuple[int, JsonDict]: + requester = await self.auth.get_user_by_req(request, allow_guest=True) set_tag("txn_id", txn_id) - return self.txns.fetch_or_execute_request( - request, self._put, request, message_type, txn_id + return await self.txns.fetch_or_execute_request( + request, + requester, + self._put, + request, + requester, + message_type, ) async def _put( - self, request: SynapseRequest, message_type: str, txn_id: str + self, + request: SynapseRequest, + requester: Requester, + message_type: str, ) -> Tuple[int, JsonDict]: - requester = await self.auth.get_user_by_req(request, allow_guest=True) - content = parse_json_object_from_request(request) assert_params_in_dict(content, ("messages",)) |