fix: #9773, fire hooks properly for priv changes (#9774)

isekai-main
Barış Soner Uşaklı 3 years ago committed by GitHub
parent f8f80e4fb3
commit 6869920e06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -65,10 +65,20 @@ categoriesAPI.setPrivilege = async (caller, data) => {
if (!userExists && !groupExists) { if (!userExists && !groupExists) {
throw new Error('[[error:no-user-or-group]]'); throw new Error('[[error:no-user-or-group]]');
} }
const privs = Array.isArray(data.privilege) ? data.privilege : [data.privilege];
await privileges.categories[data.set ? 'give' : 'rescind']( const type = data.set ? 'give' : 'rescind';
Array.isArray(data.privilege) ? data.privilege : [data.privilege], data.cid, data.member if (!privs.length) {
); throw new Error('[[error:invalid-data]]');
}
let privMethod = privileges.categories[type];
if (parseInt(data.cid, 10) === 0) {
if (privs[0].startsWith('admin:')) {
privMethod = privileges.admin[type];
} else {
privMethod = privileges.global[type];
}
}
await privMethod(privs, data.cid, data.member);
await events.log({ await events.log({
uid: caller.uid, uid: caller.uid,

Loading…
Cancel
Save