1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

Function for working out notif trigger permission

And make pushprocessor use this function
This commit is contained in:
David Baker
2017-11-02 12:04:55 +00:00
parent ff5f95227a
commit 978db89deb
2 changed files with 35 additions and 22 deletions

View File

@@ -145,28 +145,10 @@ function PushProcessor(client) {
return false;
}
const powerLevels = room.currentState.getStateEvents('m.room.power_levels', '');
if (!powerLevels || !powerLevels.getContent()) {
return false;
}
let notifLevel = 50;
if (
powerLevels.getContent().notifications &&
powerLevels.getContent().notifications[notifLevelKey]
) {
notifLevel = powerLevels.getContent().notifications[notifLevelKey];
}
// This cannot be assumed to always be set for state events
// (in particular it is never set for the room creation event
// because it preceeds the join event of the sender).
// In these cases, this condition cannot match.
if (ev.sender === null) {
return false;
}
return ev.sender.powerLevel >= notifLevel;
// Note that this should not be the current state of the room but the state at
// the point the event is in the DAG. Unfortunately the js-sdk does not store
// this.
return room.currentState.mayTriggerNotifOfType(notifLevelKey, ev.getSender());
};
const eventFulfillsRoomMemberCountCondition = function(cond, ev) {