mirror of
https://github.com/element-hq/synapse
synced 2024-09-01 23:50:22 +00:00
Fix prune_events to work with nested dicts
This commit is contained in:
parent
559a26b025
commit
e8d4a31475
1 changed files with 4 additions and 2 deletions
|
@ -45,12 +45,14 @@ def prune_event(event):
|
||||||
"membership",
|
"membership",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
event_dict = event.get_dict()
|
||||||
|
|
||||||
new_content = {}
|
new_content = {}
|
||||||
|
|
||||||
def add_fields(*fields):
|
def add_fields(*fields):
|
||||||
for field in fields:
|
for field in fields:
|
||||||
if field in event.content:
|
if field in event.content:
|
||||||
new_content[field] = event.content[field]
|
new_content[field] = event_dict["content"][field]
|
||||||
|
|
||||||
if event_type == EventTypes.Member:
|
if event_type == EventTypes.Member:
|
||||||
add_fields("membership")
|
add_fields("membership")
|
||||||
|
@ -75,7 +77,7 @@ def prune_event(event):
|
||||||
|
|
||||||
allowed_fields = {
|
allowed_fields = {
|
||||||
k: v
|
k: v
|
||||||
for k, v in event.get_dict().items()
|
for k, v in event_dict.items()
|
||||||
if k in allowed_keys
|
if k in allowed_keys
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue