mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-12-10 01:11:20 -05:00
Allow ThirdPartyRules modules to replace event content
Support returning a new event dict from `check_event_allowed`.
This commit is contained in:
parent
123711ed19
commit
617e8a4653
3 changed files with 75 additions and 9 deletions
|
|
@ -115,12 +115,12 @@ class ThirdPartyRulesTestCase(unittest.HomeserverTestCase):
|
|||
self.assertEquals(channel.result["code"], b"403", channel.result)
|
||||
|
||||
def test_modify_event(self):
|
||||
"""Tests that the module can successfully tweak an event before it is persisted.
|
||||
"""
|
||||
"""The module can return a modified version of the event"""
|
||||
# first patch the event checker so that it will modify the event
|
||||
async def check(ev: EventBase, state):
|
||||
ev.content = {"x": "y"}
|
||||
return True
|
||||
d = ev.get_dict()
|
||||
d["content"] = {"x": "y"}
|
||||
return d
|
||||
|
||||
current_rules_module().check_event_allowed = check
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue