mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 10:35:55 +01:00
fix: #8971, disallow flags of privileged users (mods, gmods, admins)
This commit is contained in:
@@ -176,12 +176,20 @@ module.exports = function (privileges) {
|
||||
};
|
||||
|
||||
privileges.posts.canFlag = async function (pid, uid) {
|
||||
const [userReputation, isAdminOrModerator] = await Promise.all([
|
||||
const targetUid = await posts.getPostField(pid, 'uid');
|
||||
const [userReputation, isAdminOrModerator, targetPrivileged, reporterPrivileged] = await Promise.all([
|
||||
user.getUserField(uid, 'reputation'),
|
||||
isAdminOrMod(pid, uid),
|
||||
user.isPrivileged(targetUid),
|
||||
user.isPrivileged(uid),
|
||||
]);
|
||||
const minimumReputation = meta.config['min:rep:flag'];
|
||||
const canFlag = isAdminOrModerator || (userReputation >= minimumReputation);
|
||||
let canFlag = isAdminOrModerator || (userReputation >= minimumReputation);
|
||||
|
||||
if (targetPrivileged && !reporterPrivileged) {
|
||||
canFlag = false;
|
||||
}
|
||||
|
||||
return { flag: canFlag };
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user