1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-14 19:22:15 +03:00

Fix power level of sentinel members

When a ppower_levels event arrived, the current member objects were
being updated but the sentinel members were not, meaning that the
power levels of RoomMember objects associated with events had stale
power levels. This was causing power level based push rules to
be wrong.
This commit is contained in:
David Baker
2017-10-23 19:07:04 +01:00
parent 7a90096077
commit fcc90e884b

View File

@@ -197,6 +197,21 @@ RoomState.prototype.setStateEvents = function(stateEvents) {
member.setPowerLevelEvent(event);
self.emit("RoomState.members", event, self, member);
});
// Go through the sentinel members and see if any of them would be
// affected by the new power levels. If so, replace the sentinel.
for (const userId of Object.keys(self._sentinels)) {
const oldSentinel = self._sentinels[userId];
const newSentinel = new RoomMember(event.getRoomId(), userId);
newSentinel.setMembershipEvent(oldSentinel.events.member, self);
newSentinel.setPowerLevelEvent(event);
if (
newSentinel.powerLevel != oldSentinel.powerLevel ||
newSentinel.powerLevelNorm != oldSentinel.powerLevelNorm
) {
self._sentinels[userId] = newSentinel;
}
}
}
});
};