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

(DRAFT) Fix global notification rules by using /pushrules instead of /m.push_rules #2093

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/molecules/global-notification/GlobalNotification.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function getTypeActions(type, highlightValue = false) {

function useGlobalNotif() {
const mx = useMatrixClient();
const pushRules = useAccountData('m.push_rules')?.getContent();
const pushRules = useAccountData('pushrules')?.getContent();
const underride = pushRules?.global?.underride ?? [];
const rulesToType = {
[DM]: notifType.ON,
Expand Down Expand Up @@ -93,7 +93,7 @@ function useGlobalNotif() {
}
ruleContent.actions = getTypeActions(type);

mx.setAccountData('m.push_rules', content);
mx.setAccountData('pushrules', content);
};

const dmRule = underride.find((rule) => rule.rule_id === DM);
Expand Down
8 changes: 4 additions & 4 deletions src/app/molecules/global-notification/KeywordNotification.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const KEYWORD = 'keyword';

function useKeywordNotif() {
const mx = useMatrixClient();
const pushRules = useAccountData('m.push_rules')?.getContent();
const pushRules = useAccountData('pushrules')?.getContent();
const override = pushRules?.global?.override ?? [];
const content = pushRules?.global?.content ?? [];

Expand Down Expand Up @@ -92,7 +92,7 @@ function useKeywordNotif() {
});
}

mx.setAccountData('m.push_rules', evtContent);
mx.setAccountData('pushrules', evtContent);
};

const addKeyword = (keyword) => {
Expand All @@ -104,11 +104,11 @@ function useKeywordNotif() {
default: false,
actions: getTypeActions(rulesToType[KEYWORD] ?? notifType.NOISY, true),
});
mx.setAccountData('m.push_rules', pushRules);
mx.setAccountData('pushrules', pushRules);
};
const removeKeyword = (rule) => {
pushRules.global.content = content.filter((r) => r.rule_id !== rule.rule_id);
mx.setAccountData('m.push_rules', pushRules);
mx.setAccountData('pushrules', pushRules);
};

const dsRule = override.find((rule) => rule.rule_id === DISPLAY_NAME);
Expand Down
2 changes: 1 addition & 1 deletion src/app/state/room-list/mutedRoomList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const useBindMutedRoomsAtom = (mx: MatrixClient, mutedAtom: typeof mutedR
const setMuted = useSetAtom(mutedAtom);

useEffect(() => {
const overrideRules = mx.getAccountData('m.push_rules')?.getContent<IPushRules>()
const overrideRules = mx.getAccountData('pushrules')?.getContent<IPushRules>()
?.global?.override;
if (overrideRules) {
const mutedRooms = overrideRules.reduce<string[]>((rooms, rule) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/utils/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const getNotificationType = (mx: MatrixClient, roomId: string): Notificat
}

if (!roomPushRule) {
const overrideRules = mx.getAccountData('m.push_rules')?.getContent<IPushRules>()
const overrideRules = mx.getAccountData('pushrules')?.getContent<IPushRules>()
?.global?.override;
if (!overrideRules) return NotificationType.Default;

Expand Down
Loading