mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-21 07:50:37 +01:00
chore: eslint prefer-template
This commit is contained in:
committed by
Julian Lam
parent
4ee0f1459d
commit
707b55b6a5
@@ -18,8 +18,8 @@ const uidToSystemGroup = {
|
||||
|
||||
helpers.isUsersAllowedTo = async function (privilege, uids, cid) {
|
||||
const [hasUserPrivilege, hasGroupPrivilege] = await Promise.all([
|
||||
groups.isMembers(uids, 'cid:' + cid + ':privileges:' + privilege),
|
||||
groups.isMembersOfGroupList(uids, 'cid:' + cid + ':privileges:groups:' + privilege),
|
||||
groups.isMembers(uids, `cid:${cid}:privileges:${privilege}`),
|
||||
groups.isMembersOfGroupList(uids, `cid:${cid}:privileges:groups:${privilege}`),
|
||||
]);
|
||||
const allowed = uids.map((uid, index) => hasUserPrivilege[index] || hasGroupPrivilege[index]);
|
||||
const result = await plugins.hooks.fire('filter:privileges:isUsersAllowedTo', { allowed: allowed, privilege: privilege, uids: uids, cid: cid });
|
||||
@@ -45,7 +45,7 @@ async function isAllowedToCids(privilege, uidOrGroupName, cids) {
|
||||
return cids.map(() => false);
|
||||
}
|
||||
|
||||
const groupKeys = cids.map(cid => 'cid:' + cid + ':privileges:groups:' + privilege);
|
||||
const groupKeys = cids.map(cid => `cid:${cid}:privileges:groups:${privilege}`);
|
||||
|
||||
// Group handling
|
||||
if (isNaN(parseInt(uidOrGroupName, 10)) && (uidOrGroupName || '').length) {
|
||||
@@ -57,12 +57,12 @@ async function isAllowedToCids(privilege, uidOrGroupName, cids) {
|
||||
return await isSystemGroupAllowedToCids(privilege, uidOrGroupName, cids);
|
||||
}
|
||||
|
||||
const userKeys = cids.map(cid => 'cid:' + cid + ':privileges:' + privilege);
|
||||
const userKeys = cids.map(cid => `cid:${cid}:privileges:${privilege}`);
|
||||
return await checkIfAllowedUser(uidOrGroupName, userKeys, groupKeys);
|
||||
}
|
||||
|
||||
async function isAllowedToPrivileges(privileges, uidOrGroupName, cid) {
|
||||
const groupKeys = privileges.map(privilege => 'cid:' + cid + ':privileges:groups:' + privilege);
|
||||
const groupKeys = privileges.map(privilege => `cid:${cid}:privileges:groups:${privilege}`);
|
||||
// Group handling
|
||||
if (isNaN(parseInt(uidOrGroupName, 10)) && (uidOrGroupName || '').length) {
|
||||
return await checkIfAllowedGroup(uidOrGroupName, groupKeys);
|
||||
@@ -73,7 +73,7 @@ async function isAllowedToPrivileges(privileges, uidOrGroupName, cid) {
|
||||
return await isSystemGroupAllowedToPrivileges(privileges, uidOrGroupName, cid);
|
||||
}
|
||||
|
||||
const userKeys = privileges.map(privilege => 'cid:' + cid + ':privileges:' + privilege);
|
||||
const userKeys = privileges.map(privilege => `cid:${cid}:privileges:${privilege}`);
|
||||
return await checkIfAllowedUser(uidOrGroupName, userKeys, groupKeys);
|
||||
}
|
||||
|
||||
@@ -94,17 +94,17 @@ async function checkIfAllowedGroup(groupName, groupKeys) {
|
||||
}
|
||||
|
||||
async function isSystemGroupAllowedToCids(privilege, uid, cids) {
|
||||
const groupKeys = cids.map(cid => 'cid:' + cid + ':privileges:groups:' + privilege);
|
||||
const groupKeys = cids.map(cid => `cid:${cid}:privileges:groups:${privilege}`);
|
||||
return await groups.isMemberOfGroups(uidToSystemGroup[uid], groupKeys);
|
||||
}
|
||||
|
||||
async function isSystemGroupAllowedToPrivileges(privileges, uid, cid) {
|
||||
const groupKeys = privileges.map(privilege => 'cid:' + cid + ':privileges:groups:' + privilege);
|
||||
const groupKeys = privileges.map(privilege => `cid:${cid}:privileges:groups:${privilege}`);
|
||||
return await groups.isMemberOfGroups(uidToSystemGroup[uid], groupKeys);
|
||||
}
|
||||
|
||||
helpers.getUserPrivileges = async function (cid, userPrivileges) {
|
||||
let memberSets = await groups.getMembersOfGroups(userPrivileges.map(privilege => 'cid:' + cid + ':privileges:' + privilege));
|
||||
let memberSets = await groups.getMembersOfGroups(userPrivileges.map(privilege => `cid:${cid}:privileges:${privilege}`));
|
||||
memberSets = memberSets.map(function (set) {
|
||||
return set.map(uid => parseInt(uid, 10));
|
||||
});
|
||||
@@ -124,7 +124,7 @@ helpers.getUserPrivileges = async function (cid, userPrivileges) {
|
||||
|
||||
helpers.getGroupPrivileges = async function (cid, groupPrivileges) {
|
||||
const [memberSets, allGroupNames] = await Promise.all([
|
||||
groups.getMembersOfGroups(groupPrivileges.map(privilege => 'cid:' + cid + ':privileges:' + privilege)),
|
||||
groups.getMembersOfGroups(groupPrivileges.map(privilege => `cid:${cid}:privileges:${privilege}`)),
|
||||
groups.getGroups('groups:createtime', 0, -1),
|
||||
]);
|
||||
|
||||
@@ -177,7 +177,7 @@ helpers.giveOrRescind = async function (method, privileges, cids, members) {
|
||||
const groupKeys = [];
|
||||
cids.forEach((cid) => {
|
||||
privileges.forEach((privilege) => {
|
||||
groupKeys.push('cid:' + cid + ':privileges:' + privilege);
|
||||
groupKeys.push(`cid:${cid}:privileges:${privilege}`);
|
||||
});
|
||||
});
|
||||
/* eslint-disable no-await-in-loop */
|
||||
|
||||
Reference in New Issue
Block a user