Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
GYU: Fix issues with audible keywords without activated mentions
Browse files Browse the repository at this point in the history
  • Loading branch information
justjanne committed Jul 10, 2023
1 parent c47ebb9 commit f28b58c
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 f28b58c

Please sign in to comment.