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

Implement MSC3873 to handle escaped dots in push rule keys #3134

Merged
merged 26 commits into from
Mar 1, 2023

Conversation

clokep
Copy link
Member

@clokep clokep commented Feb 7, 2023

This implements MSC3873 which allows for disambiguating the key used in event_match between fields that have a . in them vs. using . as a field separator.

The MSC doesn't have any backwards compatibility clauses as none of the default push rules are affected. Some custom rules might behave differently after this change. This would fix #1454.

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

Here's what your changelog entry will look like:

✨ Features

  • Implement MSC3873 to handle escaped dots in push rule keys (#3134). Fixes undefined/matrix-js-sdk#1454.

Copy link
Contributor

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

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

Some questions, and an ask for more unit tests.

spec/unit/pushprocessor.spec.ts Show resolved Hide resolved
spec/unit/pushprocessor.spec.ts Outdated Show resolved Hide resolved
src/pushprocessor.ts Outdated Show resolved Hide resolved
src/pushprocessor.ts Outdated Show resolved Hide resolved
src/pushprocessor.ts Outdated Show resolved Hide resolved
src/pushprocessor.ts Show resolved Hide resolved
src/pushprocessor.ts Outdated Show resolved Hide resolved
@clokep clokep removed the request for review from weeman1337 February 15, 2023 12:53
Copy link
Contributor

@andybalaam andybalaam left a comment

Choose a reason for hiding this comment

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

One typo, looks great!

spec/unit/pushprocessor.spec.ts Outdated Show resolved Hide resolved
@andybalaam andybalaam added this pull request to the merge queue Feb 24, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 24, 2023
@andybalaam
Copy link
Contributor

The downstream test failed https://github.com/matrix-org/matrix-js-sdk/actions/runs/4260935958/jobs/7414674597

(i.e. matrix-react-sdk tests failed with this change)

@clokep
Copy link
Member Author

clokep commented Feb 24, 2023

The downstream test failed matrix-org/matrix-js-sdk/actions/runs/4260935958/jobs/7414674597

(i.e. matrix-react-sdk tests failed with this change)

matrix-org/matrix-react-sdk#10237 should fix it (passes locally). I'm not sure if CI will pick-up on the "fix" though or not?

@clokep
Copy link
Member Author

clokep commented Feb 24, 2023

The downstream test failed matrix-org/matrix-js-sdk/actions/runs/4260935958/jobs/7414674597
(i.e. matrix-react-sdk tests failed with this change)

matrix-org/matrix-react-sdk#10237 should fix it (passes locally). I'm not sure if CI will pick-up on the "fix" though or not?

Although this now seems to be failing lint because we don't provide the keyParts when creating push rules. I think we really need to separate what we're using "internally" vs. what the protocol expects here. Everything kind of assumes they're one and the same though.

@andybalaam
Copy link
Contributor

@clokep are you blocked on me/us for this? Give me a ping if so.

@clokep
Copy link
Member Author

clokep commented Feb 27, 2023

@clokep are you blocked on me/us for this? Give me a ping if so.

No, just trying to figure out how to refactor tests after the changes I made.

@clokep
Copy link
Member Author

clokep commented Feb 27, 2023

@andybalaam I think this is ready for another look!

@@ -162,7 +168,7 @@ export class PushProcessor {
if (!newRules) newRules = {} as IPushRules;
if (!newRules.global) newRules.global = {} as PushRuleSet;
if (!newRules.global.override) newRules.global.override = [];
if (!newRules.global.override) newRules.global.underride = [];
if (!newRules.global.underride) newRules.global.underride = [];
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems to have been a separate, long-standing bug?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, how exciting. What would the symptoms have been? Maybe we can find an issue to close....

Copy link
Member Author

Choose a reason for hiding this comment

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

It was added in #2873, but that also added (on line 191) a newRules.global.underride ?? [], likely to solve the same problem? 🤷 (I don't think this would have a user-visible bug.)

Comment on lines +219 to +224
if (!newRules) newRules = {} as IPushRules;
if (!newRules.global) newRules.global = {} as PushRuleSet;
if (!newRules.global.override) newRules.global.override = [];
if (!newRules.global.room) newRules.global.room = [];
if (!newRules.global.sender) newRules.global.sender = [];
if (!newRules.global.underride) newRules.global.underride = [];
Copy link
Member Author

Choose a reason for hiding this comment

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

This was copied from rewriteDefaultRules, but it might make more sense to just skip any that are undefined instead of mutating the input value?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems fine like this, if it's more consistent.

Copy link
Contributor

@andybalaam andybalaam 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 to me.

@andybalaam andybalaam added this pull request to the merge queue Mar 1, 2023
Merged via the queue into matrix-org:develop with commit c8a4d9b Mar 1, 2023
@clokep clokep deleted the dotted-keys branch March 1, 2023 13:33
su-ex added a commit to SchildiChat/matrix-js-sdk that referenced this pull request Mar 15, 2023
* Implement MSC3758: a push rule condition to match event properties exactly ([\matrix-org#3179](matrix-org#3179)).
* Enable group calls without video and audio track by configuration of MatrixClient ([\matrix-org#3162](matrix-org#3162)). Contributed by @EnricoSchw.
* Updates to protocol used for Sign in with QR code ([\matrix-org#3155](matrix-org#3155)). Contributed by @hughns.
* Implement MSC3873 to handle escaped dots in push rule keys ([\matrix-org#3134](matrix-org#3134)). Fixes undefined/matrix-js-sdk#1454.
* Fix spec compliance issue around encrypted `m.relates_to` ([\matrix-org#3178](matrix-org#3178)).
* Fix reactions in threads sometimes causing stuck notifications ([\matrix-org#3146](matrix-org#3146)). Fixes element-hq/element-web#24000. Contributed by @justjanne.
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.

Pushrules with Dotted Value keys break
3 participants