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 account linked to committer's email address

View File

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