Skip to content

Commit

Permalink
GYU: Fix issues with audible keywords without activated mentions (#11218
Browse files Browse the repository at this point in the history
)
  • Loading branch information
justjanne committed Jul 11, 2023
1 parent d014756 commit b179f55
Show file tree
Hide file tree
Showing 3 changed files with 411 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/models/notificationsettings/toNotificationSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export function toNotificationSettings(
supportsIntentionalMentions && standardRules.get(RuleId.IsUserMention),
standardRules.get(RuleId.ContainsUserName),
standardRules.get(RuleId.ContainsDisplayName),
...contentRules,
]),
people: determineSound(dmRules),
},
Expand Down
33 changes: 33 additions & 0 deletions test/models/notificationsettings/NotificationSettings-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,37 @@ describe("NotificationSettings", () => {
expect(pendingChanges.deleted).toHaveLength(0);
expect(pendingChanges.updated).toHaveLength(0);
});

it("correctly handles audible keywords without mentions settings", async () => {
const pushRules = (await import("./pushrules_bug_keyword_only.json")) as IPushRules;
const model = toNotificationSettings(pushRules, false);
const pendingChanges = reconcileNotificationSettings(pushRules, model, false);
const expectedModel: NotificationSettings = {
globalMute: false,
defaultLevels: {
dm: RoomNotifState.MentionsOnly,
room: RoomNotifState.MentionsOnly,
},
sound: {
calls: "ring",
mentions: "default",
people: undefined,
},
activity: {
bot_notices: true,
invite: true,
status_event: false,
},
mentions: {
user: false,
room: true,
keywords: true,
},
keywords: ["janne"],
};
expect(model).toEqual(expectedModel);
expect(pendingChanges.added).toHaveLength(0);
expect(pendingChanges.deleted).toHaveLength(0);
expect(pendingChanges.updated).toHaveLength(0);
});
});
Loading

0 comments on commit b179f55

Please sign in to comment.