-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: unfreeze notification_levels for PushRuleEvaluator #18103
Open
c-cal
wants to merge
10
commits into
element-hq:develop
Choose a base branch
from
c-cal:patch-2
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b7a2e9f
fix: unfreeze notification_levels for the Rust implementation of Push…
c-cal 6edb079
add a changelog entry
c-cal 1e7379f
Merge branch 'develop' into patch-2
c-cal cfd870f
Merge branch 'develop' into patch-2
c-cal dfbefd8
Merge branch 'develop' into patch-2
c-cal 073d3c2
Merge branch 'develop' into patch-2
c-cal 8196952
Revert "fix: unfreeze notification_levels for the Rust implementation…
c-cal c637a3c
add event.unfreeze method
c-cal c8a4628
unfreeze event after executing all check_event_allowed callbacks
c-cal d776e8d
Merge branch 'develop' into patch-2
c-cal 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 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Fixed a bug that disturbed room creation when a check_event_allowed callback was registered by a module and power_level Notifications mapping exists. | ||
|
||
Contributed by @c-cal |
This file contains 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
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.
I've just had a thought on how we could solve all of the cases in #18117 pretty elegantly without having to muck about in the downstream code,
Instead of calling
unfreeze
at the spot we're trying to use it here, we couldunfreeze
after we're done with the frozen event in the third party module callbacks (where we calledfreeze
in the first place).(
unfreeze
after we run all of the callbacks)synapse/synapse/module_api/callbacks/third_party_event_rules_callbacks.py
Lines 291 to 316 in a0b7047
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.
@c-cal or @blackmad (author of #18066) Do you have an interest in making that change?
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.
In this case,
unfreeze()
must be applied toevent._dict
, but since it's a “private” attribute, it would probably be cleaner to do it directly from a dedicated method (eg:event.unfreeze
). Is it reasonable to make such a method so easily accessible to callbacks?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.
This is a good point to consider. We could update the name to mark the method as internal (
event._freeze()
) which would discourage people from using it by convention.Perhaps, we should just make a copy of the event that we freeze. Since we're taking the hit to freeze things anyway, it doesn't seem unreasonable to just make the event copy and freeze. We can use
clone_event(...)
and this prevents any possible tampering problems. If the clone is deep enough, we could avoid freezing altogether as we aren't really worried if they modify their own copy but I have a feeling we don't clone deep enough for theprev_event_ids
and other lists etc.There is
FrozenEvent
but it doesn't actually freeze the event all the time because it's "expensive" (see theUSE_FROZEN_DICTS
logic) so we can't use that.