Merge pull request #3436 from matrix-org/travis/deactivate-release

Fix synapse deactivate button for release
This commit is contained in:
David Baker 2019-09-13 13:26:19 +01:00 committed by GitHub
commit e548e4d7a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -636,8 +636,20 @@ module.exports = withMatrixClient(React.createClass({
},
_calculateOpsPermissions: async function(member) {
let canDeactivate = false;
if (this.context.matrixClient) {
try {
canDeactivate = await this.context.matrixClient.isSynapseAdministrator();
} catch (e) {
console.error(e);
}
}
const defaultPerms = {
can: {},
can: {
// Calculate permissions for Synapse before doing the PL checks
synapseDeactivate: canDeactivate,
},
muted: false,
};
const room = this.props.matrixClient.getRoom(member.roomId);
@ -651,9 +663,10 @@ module.exports = withMatrixClient(React.createClass({
const them = member;
return {
can: await this._calculateCanPermissions(
me, them, powerLevels.getContent(),
),
can: {
...defaultPerms.can,
...await this._calculateCanPermissions(me, them, powerLevels.getContent()),
},
muted: this._isMuted(them, powerLevels.getContent()),
isTargetMod: them.powerLevel > powerLevels.getContent().users_default,
};
@ -670,9 +683,6 @@ module.exports = withMatrixClient(React.createClass({
redactMessages: false,
};
// Calculate permissions for Synapse before doing the PL checks
can.synapseDeactivate = await this.context.matrixClient.isSynapseAdministrator();
const canAffectUser = them.powerLevel < me.powerLevel || isMe;
if (!canAffectUser) {
//console.log("Cannot affect user: %s >= %s", them.powerLevel, me.powerLevel);