Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix modifying events in ThirdPartyRules modules #8564

Merged
merged 1 commit into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/8564.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support modifying event content in `ThirdPartyRules` modules.
2 changes: 1 addition & 1 deletion synapse/events/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def is_state(self):
return self._state_key is not None

async def build(
self, prev_event_ids: List[str], auth_event_ids: Optional[List[str]]
self, prev_event_ids: List[str], auth_event_ids: Optional[List[str]],
) -> EventBase:
"""Transform into a fully signed and hashed event

Expand Down
7 changes: 6 additions & 1 deletion synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,12 @@ async def _rebuild_event_after_third_party_rules(
for k, v in original_event.internal_metadata.get_dict().items():
setattr(builder.internal_metadata, k, v)

event = await builder.build(prev_event_ids=original_event.prev_event_ids())
# the event type hasn't changed, so there's no point in re-calculating the
# auth events.
event = await builder.build(
prev_event_ids=original_event.prev_event_ids(),
auth_event_ids=original_event.auth_event_ids(),
)

# we rebuild the event context, to be on the safe side. If nothing else,
# delta_ids might need an update.
Expand Down