Enable cancellation of `GET /members` and `GET /state` requests (#12708)
Enable cancellation of `GET /rooms/$room_id/members`, `GET /rooms/$room_id/state` and `GET /rooms/$room_id/state/$state_key/*` requests. Signed-off-by: Sean Quah <seanq@element.io>
This commit is contained in:
parent
db10f2c037
commit
bf7ce92bf7
|
@ -0,0 +1 @@
|
||||||
|
Enable cancellation of `GET /rooms/$room_id/members`, `GET /rooms/$room_id/state` and `GET /rooms/$room_id/state/$event_type/*` requests.
|
|
@ -139,7 +139,9 @@ def cancellable(method: F) -> F:
|
||||||
async def on_GET(self, request: SynapseRequest) -> ...:
|
async def on_GET(self, request: SynapseRequest) -> ...:
|
||||||
...
|
...
|
||||||
"""
|
"""
|
||||||
if method.__name__ not in _cancellable_method_names:
|
if method.__name__ not in _cancellable_method_names and not any(
|
||||||
|
method.__name__.startswith(prefix) for prefix in _cancellable_method_names
|
||||||
|
):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"@cancellable decorator can only be applied to servlet methods."
|
"@cancellable decorator can only be applied to servlet methods."
|
||||||
)
|
)
|
||||||
|
|
|
@ -34,7 +34,7 @@ from synapse.api.errors import (
|
||||||
)
|
)
|
||||||
from synapse.api.filtering import Filter
|
from synapse.api.filtering import Filter
|
||||||
from synapse.events.utils import format_event_for_client_v2
|
from synapse.events.utils import format_event_for_client_v2
|
||||||
from synapse.http.server import HttpServer
|
from synapse.http.server import HttpServer, cancellable
|
||||||
from synapse.http.servlet import (
|
from synapse.http.servlet import (
|
||||||
ResolveRoomIdMixin,
|
ResolveRoomIdMixin,
|
||||||
RestServlet,
|
RestServlet,
|
||||||
|
@ -143,6 +143,7 @@ class RoomStateEventRestServlet(TransactionRestServlet):
|
||||||
self.__class__.__name__,
|
self.__class__.__name__,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@cancellable
|
||||||
def on_GET_no_state_key(
|
def on_GET_no_state_key(
|
||||||
self, request: SynapseRequest, room_id: str, event_type: str
|
self, request: SynapseRequest, room_id: str, event_type: str
|
||||||
) -> Awaitable[Tuple[int, JsonDict]]:
|
) -> Awaitable[Tuple[int, JsonDict]]:
|
||||||
|
@ -153,6 +154,7 @@ class RoomStateEventRestServlet(TransactionRestServlet):
|
||||||
) -> Awaitable[Tuple[int, JsonDict]]:
|
) -> Awaitable[Tuple[int, JsonDict]]:
|
||||||
return self.on_PUT(request, room_id, event_type, "")
|
return self.on_PUT(request, room_id, event_type, "")
|
||||||
|
|
||||||
|
@cancellable
|
||||||
async def on_GET(
|
async def on_GET(
|
||||||
self, request: SynapseRequest, room_id: str, event_type: str, state_key: str
|
self, request: SynapseRequest, room_id: str, event_type: str, state_key: str
|
||||||
) -> Tuple[int, JsonDict]:
|
) -> Tuple[int, JsonDict]:
|
||||||
|
@ -481,6 +483,7 @@ class RoomMemberListRestServlet(RestServlet):
|
||||||
self.auth = hs.get_auth()
|
self.auth = hs.get_auth()
|
||||||
self.store = hs.get_datastores().main
|
self.store = hs.get_datastores().main
|
||||||
|
|
||||||
|
@cancellable
|
||||||
async def on_GET(
|
async def on_GET(
|
||||||
self, request: SynapseRequest, room_id: str
|
self, request: SynapseRequest, room_id: str
|
||||||
) -> Tuple[int, JsonDict]:
|
) -> Tuple[int, JsonDict]:
|
||||||
|
@ -602,6 +605,7 @@ class RoomStateRestServlet(RestServlet):
|
||||||
self.message_handler = hs.get_message_handler()
|
self.message_handler = hs.get_message_handler()
|
||||||
self.auth = hs.get_auth()
|
self.auth = hs.get_auth()
|
||||||
|
|
||||||
|
@cancellable
|
||||||
async def on_GET(
|
async def on_GET(
|
||||||
self, request: SynapseRequest, room_id: str
|
self, request: SynapseRequest, room_id: str
|
||||||
) -> Tuple[int, List[JsonDict]]:
|
) -> Tuple[int, List[JsonDict]]:
|
||||||
|
|
Loading…
Reference in New Issue