This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add a new third party callback check_event_allowed_v2 that is compatible with new batch persisting mechanisms.
#15131
Closed
Closed
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
aab5fb6
add check_event_allowed_v2
H-Shay 2e14bc3
change callsites to reflect new function signature
H-Shay 5cebb37
update tests to reflect new function signature
H-Shay b564f29
add a new test to check sending an additional event into room
H-Shay 7b610fc
update docs with information on v2 callback
H-Shay 9b702df
newsfragment
H-Shay a9b0093
update changelog
H-Shay 2ab6cec
add clearer return values
H-Shay 7fc4874
Merge branch 'develop' into shay/rework_module
H-Shay 13676fb
more develop merge fix
H-Shay d4ed0a4
requested changes
H-Shay ad32583
Merge branch 'develop' into shay/rework_module
H-Shay 4809a0c
merge in develop
H-Shay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1291,39 +1291,43 @@ async def create_event( | |
| if encrypt_tp_event: | ||
| third_party_events_to_append.append(encrypt_tp_event) | ||
|
|
||
| for event_dict in third_party_events_to_append: | ||
| ( | ||
| event, | ||
| unpersisted_context, | ||
| _, | ||
| ) = await self.event_creation_handler.create_event( | ||
| creator, | ||
| event_dict, | ||
| prev_event_ids=prev_event, | ||
| state_map=state_map, | ||
| for_batch=True, | ||
| current_state_group=current_state_group, | ||
| ) | ||
| context = await unpersisted_context.persist(event) | ||
| events_to_send.append((event, context)) | ||
|
|
||
| if "name" in room_config: | ||
| name = room_config["name"] | ||
| name_event, name_context = await create_event( | ||
| name_event, name_context, name_tp_event = await create_event( | ||
| EventTypes.Name, | ||
| {"name": name}, | ||
| True, | ||
| ) | ||
| events_to_send.append((name_event, name_context)) | ||
| if name_tp_event: | ||
| third_party_events_to_append.append(name_tp_event) | ||
|
|
||
| if "topic" in room_config: | ||
| topic = room_config["topic"] | ||
| topic_event, topic_context = await create_event( | ||
| topic_event, topic_context, topic_tp_event = await create_event( | ||
| EventTypes.Topic, | ||
| {"topic": topic}, | ||
| True, | ||
| ) | ||
| events_to_send.append((topic_event, topic_context)) | ||
| if topic_tp_event: | ||
| third_party_events_to_append.append(topic_tp_event) | ||
|
|
||
| for event_dict in third_party_events_to_append: | ||
| ( | ||
| event, | ||
| unpersisted_context, | ||
| _, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so (if I can read correctly) we don't let the callbacks on third-party events themselves generate more events? This could be worth putting in a comment and in the docs for the callback? |
||
| ) = await self.event_creation_handler.create_event( | ||
| creator, | ||
| event_dict, | ||
| prev_event_ids=prev_event, | ||
| state_map=state_map, | ||
| for_batch=True, | ||
| current_state_group=current_state_group, | ||
| ) | ||
| context = await unpersisted_context.persist(event) | ||
| events_to_send.append((event, context)) | ||
|
|
||
| datastore = self.hs.get_datastores().state | ||
| events_and_context = ( | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we're going for RFC conventions (the capitals make me feel like it), MUST NOT is the term to use