mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-22 19:43:16 +00:00
Merge remote-tracking branch 'upstream/master' into milestoneV1/routes/implement/emojis
This commit is contained in:
commit
7cfca122ae
11 files changed
+54
-21
No files matched your search
@@ -129,6 +129,7 @@ export interface ConfigValue {
|
||||
disabled: boolean;
|
||||
requireCaptcha: boolean;
|
||||
requireInvite: boolean;
|
||||
guestsRequireInvite: boolean;
|
||||
allowNewRegistration: boolean;
|
||||
allowMultipleAccounts: boolean;
|
||||
blockProxies: boolean;
|
||||
@@ -279,6 +280,7 @@ export const DefaultConfigOptions: ConfigValue = {
|
||||
},
|
||||
disabled: false,
|
||||
requireInvite: false,
|
||||
guestsRequireInvite: true,
|
||||
requireCaptcha: true,
|
||||
allowNewRegistration: true,
|
||||
allowMultipleAccounts: true,
|
||||
|
||||
@@ -12,6 +12,7 @@ export const Config = {
|
||||
if (config) return config;
|
||||
pairs = await ConfigEntity.find();
|
||||
config = pairsToConfig(pairs);
|
||||
console.log(config.guild.autoJoin);
|
||||
|
||||
return this.set((config || {}).merge(DefaultConfigOptions));
|
||||
},
|
||||
@@ -47,16 +48,18 @@ function pairsToConfig(pairs: ConfigEntity[]) {
|
||||
|
||||
pairs.forEach((p) => {
|
||||
const keys = p.key.split("_");
|
||||
let prev = "";
|
||||
let obj = value;
|
||||
let prev = "";
|
||||
let prevObj = obj;
|
||||
let i = 0;
|
||||
|
||||
for (const key of keys) {
|
||||
if (Number(key) && !obj[prev]) obj = obj[prev] = [];
|
||||
if (!isNaN(Number(key)) && !prevObj[prev]?.length) prevObj[prev] = obj = [];
|
||||
if (i++ === keys.length - 1) obj[key] = p.value;
|
||||
else if (!obj[key]) obj[key] = {};
|
||||
|
||||
prev = key;
|
||||
prevObj = obj;
|
||||
obj = obj[key];
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user