mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-23 10:05:55 +03:00
Validate input parameters for the sendToDevice API. (#8975)
This makes the "messages" key in the content required. This is currently optional in the spec, but that seems to be an error.
This commit is contained in:
parent
cfcf5541b4
commit
14a7371375
2 changed files with 3 additions and 1 deletions
1
changelog.d/8975.bugfix
Normal file
1
changelog.d/8975.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Add validation to the `sendToDevice` API to raise a missing parameters error instead of a 500 error.
|
|
@ -17,7 +17,7 @@ import logging
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
from synapse.http import servlet
|
from synapse.http import servlet
|
||||||
from synapse.http.servlet import parse_json_object_from_request
|
from synapse.http.servlet import assert_params_in_dict, parse_json_object_from_request
|
||||||
from synapse.logging.opentracing import set_tag, trace
|
from synapse.logging.opentracing import set_tag, trace
|
||||||
from synapse.rest.client.transactions import HttpTransactionCache
|
from synapse.rest.client.transactions import HttpTransactionCache
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ class SendToDeviceRestServlet(servlet.RestServlet):
|
||||||
requester = await self.auth.get_user_by_req(request, allow_guest=True)
|
requester = await self.auth.get_user_by_req(request, allow_guest=True)
|
||||||
|
|
||||||
content = parse_json_object_from_request(request)
|
content = parse_json_object_from_request(request)
|
||||||
|
assert_params_in_dict(content, ("messages",))
|
||||||
|
|
||||||
sender_user_id = requester.user.to_string()
|
sender_user_id = requester.user.to_string()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue