fix: upgrade script

v1.18.x
Barış Soner Uşaklı 4 years ago
parent 59bbede8c7
commit 1289c10568

@ -60,34 +60,36 @@ module.exports = {
}); });
await db.delete('users:notvalidated'); await db.delete('users:notvalidated');
await updatePrivilges();
},
};
async function updatePrivilges() {
// if email confirmation is required
// give chat, posting privs to "verified-users" group
// remove chat, posting privs from "registered-users" group
if (meta.config.requireEmailConfirmation) {
const cids = await db.getSortedSetRevRange('categories:cid', 0, -1); const cids = await db.getSortedSetRevRange('categories:cid', 0, -1);
const canChat = await privileges.global.canGroup('chat', 'registered-users'); const canChat = await privileges.global.canGroup('chat', 'registered-users');
// if email confirmation is required if (canChat) {
// give chat, posting privs to "verified-users" group await privileges.global.give(['groups:chat'], 'verified-users');
// remove chat, posting privs from "registered-users" group await privileges.global.rescind(['groups:chat'], 'registered-users');
if (1 || meta.config.requireEmailConfirmation) { }
if (canChat) { for (const cid of cids) {
await privileges.global.give(['groups:chat'], 'verified-users'); /* eslint-disable no-await-in-loop */
await privileges.global.rescind(['groups:chat'], 'registered-users'); const data = await privileges.categories.list(cid);
}
for (const cid of cids) {
/* eslint-disable no-await-in-loop */
const data = await privileges.categories.list(cid);
const registeredUsersPrivs = data.groups.find(d => d.name === 'registered-users').privileges; const registeredUsersPrivs = data.groups.find(d => d.name === 'registered-users').privileges;
if (registeredUsersPrivs['groups:topics:create']) { if (registeredUsersPrivs['groups:topics:create']) {
await privileges.categories.give(['groups:topics:create'], cid, 'verified-users'); await privileges.categories.give(['groups:topics:create'], cid, 'verified-users');
await privileges.categories.rescind(['groups:topics:create'], cid, 'registered-users'); await privileges.categories.rescind(['groups:topics:create'], cid, 'registered-users');
} }
if (registeredUsersPrivs['groups:topics:reply']) { if (registeredUsersPrivs['groups:topics:reply']) {
await privileges.categories.give(['groups:topics:reply'], cid, 'verified-users'); await privileges.categories.give(['groups:topics:reply'], cid, 'verified-users');
await privileges.categories.rescind(['groups:topics:reply'], cid, 'registered-users'); await privileges.categories.rescind(['groups:topics:reply'], cid, 'registered-users');
}
} }
} }
}, }
}; }

Loading…
Cancel
Save