Skip to content
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

First cut of a module to automatically change push rule actions when new users register #1

Merged
merged 9 commits into from
Apr 25, 2022

Conversation

babolivier
Copy link
Contributor

@babolivier babolivier commented Apr 7, 2022

This work is happening in the context of the Tchap mainlining. See https://github.com/matrix-org/matrix-dinsic/issues/856 for more information about why this specific module is needed.

The mypy failure is expected since matrix-org/synapse#12406 hasn't been released in a stable version of Synapse yet. It passes locally when using that PR's branch.

Ideally the module should check for invalid push rules at startup but implementing a push rules parser sounds like a pretty big job, and I'm not sure it'd be worth it.

@babolivier babolivier requested a review from a team as a code owner April 7, 2022 16:45
@reivilibre
Copy link

I don't have access to the issue you linked for context, but I wonder whether we should be using the 'server-default rules' mechanism built in to push rules, perhaps exposing it as a config option? (as grim as config options can be).

@babolivier babolivier removed the request for review from a team April 8, 2022 13:12
@babolivier
Copy link
Contributor Author

Removing the request for review because this is not actually the right way to resolve this issue.

Also, @reivilibre:

the 'server-default rules' mechanism built in to push rules

What are you referring to by this?

If you're suggesting allowing the config to change the server's default push rules, this sounds like a bad idea to me because

  1. we don't want existing rules to change under the feet of users who already exist
  2. Synapse's default push rules are defined by the spec
  3. the push rules code in Synapse is very non-trivial to hack into

@babolivier babolivier requested a review from a team April 8, 2022 14:25
@babolivier
Copy link
Contributor Author

I've updated the module to change the push rule's actions instead of creating a new one, which is a better approach to the problem this module is trying to solve.

@reivilibre
Copy link

If you're suggesting allowing the config to change the server's default push rules, this sounds like a bad idea to me because

  1. we don't want existing rules to change under the feet of users who already exist

This is fair enough but I wasn't sure whether this was a requirement or not without context.

  1. Synapse's default push rules are defined by the spec

The spec defines a minimal set of default rules, but specifies that homeservers are able to specify others, so I don't think this point is pertinent here.

  1. the push rules code in Synapse is very non-trivial to hack into

Adding server-default push rules doesn't seem that difficult, though. It's not as though you need to hack into the way they're evaluated :).

@babolivier
Copy link
Contributor Author

babolivier commented Apr 8, 2022

This is fair enough but I wasn't sure whether this was a requirement or not without context.

Yeah, I was under the impression that everyone in the Synapse team had access to that repo, but that's not the case :/
I've asked for its access to be broadened.

but specifies that homeservers are able to specify others

I've missed that. In this case, it might not be too bad (but in general my experience with adding "simple" things to the push rules management code of Synapse has been that it's never as simple as you initially believe it to be).
However, the goal of this work is to mainline matrix-org/synapse-dinsic#60, which is about modifying existing push rules rather than creating new ones (hence the change of editing actions vs creating new rules), and it feels to me like more work to do that with additional server-side rules (instead of automatically modifying existing ones).

(also actually ignore what I said earlier, we don't really care about changing this under the feet of existing users because it shouldn't be an actual change in UX)

@babolivier babolivier changed the title First cut of a module to automatically set new push rules when new users register First cut of a module to automatically change push rule actions when new users register Apr 8, 2022
@babolivier
Copy link
Contributor Author

Another issue with using configurable server-side rules is that if you change them they're not automatically sent to clients of existing users, despite the new rules applying to them as well. So the notification rules would get out of sync between the clients and the server until the clients hit the "clear cache and reload" (or equivalent) button.

Copy link

@squahtx squahtx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, assuming matrix-org/synapse#12406 lands

synapse_patch_push_rules/__init__.py Outdated Show resolved Hide resolved
synapse_patch_push_rules/__init__.py Outdated Show resolved Hide resolved
@babolivier babolivier requested a review from squahtx April 25, 2022 16:45
Copy link

@squahtx squahtx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@babolivier babolivier merged commit e4da823 into main Apr 25, 2022
@babolivier babolivier deleted the babolivier/init branch April 25, 2022 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants