-
Notifications
You must be signed in to change notification settings - Fork 236
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
base: develop
Are you sure you want to change the base?
Conversation
…RuleEvaluator, which can't handle immutabledict
@@ -412,7 +413,7 @@ async def _action_for_event_by_user( | |||
# Note that this is done automatically for the sender's power level by | |||
# _get_power_levels_and_sender_level in its call to get_user_power_level | |||
# (even for room V10.) | |||
notification_levels = power_levels.get("notifications", {}) | |||
notification_levels = unfreeze(power_levels.get("notifications", {})) |
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 could unfreeze
after we're done with the frozen event in the third party module callbacks (where we called freeze
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
# Ensure that the event is frozen, to make sure that the module is not tempted | |
# to try to modify it. Any attempt to modify it at this point will invalidate | |
# the hashes and signatures. | |
event.freeze() | |
for callback in self._check_event_allowed_callbacks: | |
try: | |
res, replacement_data = await delay_cancellation( | |
callback(event, state_events) | |
) | |
except CancelledError: | |
raise | |
except SynapseError as e: | |
# FIXME: Being able to throw SynapseErrors is relied upon by | |
# some modules. PR https://github.com/matrix-org/synapse/pull/10386 | |
# accidentally broke this ability. | |
# That said, we aren't keen on exposing this implementation detail | |
# to modules and we should one day have a proper way to do what | |
# is wanted. | |
# This module callback needs a rework so that hacks such as | |
# this one are not necessary. | |
raise e | |
except Exception: | |
raise ModuleFailedException( | |
"Failed to run `check_event_allowed` module API callback" | |
) |
…which can't handle immutabledict
Pull Request Checklist
Pull request is based on the develop branch
Pull request includes a changelog file. The entry should:
EventStore
toEventWorkerStore
.".code blocks
.Code style is correct
(run the linters)
fixes: check_event_allowed callback from the module API cause a TypeError #18101