diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2022-03-16 12:17:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-16 12:17:39 -0400 |
commit | 96274565ff0dbb7d21b02b04fcef115330426707 (patch) | |
tree | 31489f1b026168cd97fb8296a7c753b8d025d075 /synapse/events/utils.py | |
parent | Changelog tweaks (diff) | |
download | synapse-96274565ff0dbb7d21b02b04fcef115330426707.tar.xz |
Fix bundling aggregations if unsigned is not a returned event field. (#12234)
An error occured if a filter was supplied with `event_fields` which did not include `unsigned`. In that case, bundled aggregations are still added as the spec states it is allowed for servers to add additional fields.
Diffstat (limited to 'synapse/events/utils.py')
-rw-r--r-- | synapse/events/utils.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/synapse/events/utils.py b/synapse/events/utils.py index b2a237c1e0..a0520068e0 100644 --- a/synapse/events/utils.py +++ b/synapse/events/utils.py @@ -530,9 +530,12 @@ class EventClientSerializer: # Include the bundled aggregations in the event. if serialized_aggregations: - serialized_event["unsigned"].setdefault("m.relations", {}).update( - serialized_aggregations - ) + # There is likely already an "unsigned" field, but a filter might + # have stripped it off (via the event_fields option). The server is + # allowed to return additional fields, so add it back. + serialized_event.setdefault("unsigned", {}).setdefault( + "m.relations", {} + ).update(serialized_aggregations) def serialize_events( self, |