0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-17 07:21:37 +01:00

Check missing fields in event_from_pdu_json

Return a 400 rather than a 500 when somebody messes up their send_join
This commit is contained in:
Richard van der Hoff 2017-12-30 18:40:19 +00:00
parent 3079f80d4a
commit bd91857028

View file

@ -18,6 +18,7 @@ from synapse.api.errors import SynapseError
from synapse.crypto.event_signing import check_event_content_hash from synapse.crypto.event_signing import check_event_content_hash
from synapse.events import FrozenEvent from synapse.events import FrozenEvent
from synapse.events.utils import prune_event from synapse.events.utils import prune_event
from synapse.http.servlet import assert_params_in_request
from synapse.util import unwrapFirstError, logcontext from synapse.util import unwrapFirstError, logcontext
from twisted.internet import defer from twisted.internet import defer
@ -181,7 +182,13 @@ def event_from_pdu_json(pdu_json, outlier=False):
Returns: Returns:
FrozenEvent FrozenEvent
Raises:
SynapseError: if the pdu is missing required fields
""" """
# we could probably enforce a bunch of other fields here (room_id, sender,
# origin, etc etc)
assert_params_in_request(pdu_json, ('event_id', 'type'))
event = FrozenEvent( event = FrozenEvent(
pdu_json pdu_json
) )