fix: #10255, create verified/unverified groups on install

This commit is contained in:
Barış Soner Uşaklı
2022-02-07 10:30:46 -05:00
parent 0823992d63
commit 08f2a05053

View File

@@ -222,6 +222,35 @@ async function enableDefaultTheme() {
});
}
async function createDefaultUserGroups() {
const groups = require('./groups');
async function createGroup(name) {
await groups.create({
name: name,
hidden: 1,
private: 1,
system: 1,
disableLeave: 1,
disableJoinRequests: 1,
});
}
const [verifiedExists, unverifiedExists, bannedExists] = await groups.exists([
'verified-users', 'unverified-users', 'banned-users',
]);
if (!verifiedExists) {
await createGroup('verified-users');
}
if (!unverifiedExists) {
await createGroup('unverified-users');
}
if (!bannedExists) {
await createGroup('banned-users');
}
}
async function createAdministrator() {
const Groups = require('./groups');
const memberCount = await Groups.getMemberCount('administrators');
@@ -498,6 +527,7 @@ install.setup = async function () {
await setupDefaultConfigs();
await enableDefaultTheme();
await createCategories();
await createDefaultUserGroups();
const adminInfo = await createAdministrator();
await createGlobalModeratorsGroup();
await giveGlobalPrivileges();