Allow a notification keyword to start with a dot (#34574)
Both notification settings tabs stored a keyword under a push rule whose id was the keyword itself. Homeservers reserve the rule ids beginning with a dot for the rules they define, and Synapse refuses to create any other, so saving a keyword such as "...push complete" failed outright and the whole save was reported as an error. The rule id is an internal name that the user never sees — both tabs list keywords by the rule's pattern — so it is the id that gives way. It now drops the leading dots while the pattern keeps the keyword exactly as it was typed, which is what is matched against messages. Two keywords can want the same id that way, so a number is appended when one is taken, which also keeps "banana" from overwriting the rule for ".banana". Tests: the shared reconciler and the older tab both store a dotted keyword under an accepted id, and two keywords differing only by a leading dot get an id each.
This commit is contained in:
@@ -858,6 +858,20 @@ describe("<Notifications />", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("adds a keyword that starts with a dot", async () => {
|
||||
await getComponentAndWait();
|
||||
|
||||
await userEvent.type(screen.getByLabelText("Keyword"), ".jest");
|
||||
|
||||
fireEvent.click(screen.getByText("Add"));
|
||||
|
||||
// The homeserver rejects a rule id beginning with a dot, so only the pattern keeps it.
|
||||
expect(mockClient.addPushRule).toHaveBeenCalledWith("global", PushRuleKind.ContentSpecific, "jest", {
|
||||
actions: [PushRuleActionName.Notify, { set_tweak: "highlight", value: false }],
|
||||
pattern: ".jest",
|
||||
});
|
||||
});
|
||||
|
||||
it("adds a new keyword with same actions as existing rules when keywords rule is off", async () => {
|
||||
const offContentRule = {
|
||||
...bananaRule,
|
||||
|
||||
Reference in New Issue
Block a user