diff options
author | H. Shay <hillerys@element.io> | 2023-03-16 14:31:10 -0700 |
---|---|---|
committer | H. Shay <hillerys@element.io> | 2023-03-16 14:31:10 -0700 |
commit | d4ed0a48c185f9c2aae4be48309e14b449d7aa61 (patch) | |
tree | a6f070f45e415b410f554fb4d0f6563fa2e42d09 | |
parent | more develop merge fix (diff) | |
download | synapse-d4ed0a48c185f9c2aae4be48309e14b449d7aa61.tar.xz |
requested changes
-rw-r--r-- | docs/modules/third_party_rules_callbacks.md | 4 | ||||
-rw-r--r-- | synapse/events/third_party_rules.py | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/docs/modules/third_party_rules_callbacks.md b/docs/modules/third_party_rules_callbacks.md index d0eaf77f76..f301bfdcba 100644 --- a/docs/modules/third_party_rules_callbacks.md +++ b/docs/modules/third_party_rules_callbacks.md @@ -52,12 +52,12 @@ event with new data by returning the new event's data as a dictionary. In order that, it is recommended the module calls `event.get_dict()` to get the current event as a dictionary, and modify the returned dictionary accordingly. -Module writers may also wish to use this check to send an event into the room concurrent +Module writers may also wish to use this check to send a second event into the room along with the event being checked, if this is the case the module writer must provide a dict that will form the basis of the event that is to be added to the room and it must be returned by `check_event_allowed_v2`. This dict will then be turned into an event at the appropriate time and it will be persisted after the event that triggered it, and if the event that triggered it is in a batch of events for persisting, it will be added to the -end of that batch. +end of that batch. Note that the event MAY NOT be a membership event. If `check_event_allowed_v2` raises an exception, the module is assumed to have failed. The event will not be accepted but is not treated as explicitly rejected, either. diff --git a/synapse/events/third_party_rules.py b/synapse/events/third_party_rules.py index 1b7c6de974..a977faeb25 100644 --- a/synapse/events/third_party_rules.py +++ b/synapse/events/third_party_rules.py @@ -191,6 +191,7 @@ class ThirdPartyEventRules: def register_third_party_rules_callbacks( self, check_event_allowed: Optional[CHECK_EVENT_ALLOWED_CALLBACK] = None, + check_event_allowed_v2: Optional[CHECK_EVENT_ALLOWED_V2_CALLBACK] = None, on_create_room: Optional[ON_CREATE_ROOM_CALLBACK] = None, check_threepid_can_be_invited: Optional[ CHECK_THREEPID_CAN_BE_INVITED_CALLBACK @@ -217,6 +218,9 @@ class ThirdPartyEventRules: if check_event_allowed is not None: self._check_event_allowed_callbacks.append(check_event_allowed) + if check_event_allowed_v2 is not None: + self._check_event_allowed_v2_callbacks.append(check_event_allowed_v2) + if on_create_room is not None: self._on_create_room_callbacks.append(on_create_room) |