summary refs log tree commit diff
path: root/util/src
diff options
context:
space:
mode:
authorLobo Metalúrgico <43734867+LoboMetalurgico@users.noreply.github.com>2021-10-09 10:39:26 -0300
committerLobo Metalúrgico <43734867+LoboMetalurgico@users.noreply.github.com>2021-10-09 10:39:26 -0300
commit3a5c511f1b59b8f607e7b99cd1d3edb7d13a3100 (patch)
treea1d007e766c2c48cbc5e45032c667a63821914ae /util/src
parent(api): fix route name (diff)
parentMerge branch 'master' of http://github.com/fosscord/fosscord-server (diff)
downloadserver-3a5c511f1b59b8f607e7b99cd1d3edb7d13a3100.tar.xz
Merge remote-tracking branch 'upstream/master' into milestoneV1/routes/implement/emojis
Diffstat (limited to 'util/src')
-rw-r--r--util/src/entities/Config.ts2
-rw-r--r--util/src/util/Config.ts7
2 files changed, 7 insertions, 2 deletions
diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts
index ed2bcab3..6760187f 100644
--- a/util/src/entities/Config.ts
+++ b/util/src/entities/Config.ts
@@ -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,
diff --git a/util/src/util/Config.ts b/util/src/util/Config.ts
index 255f425d..eeeaa2ce 100644
--- a/util/src/util/Config.ts
+++ b/util/src/util/Config.ts
@@ -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];
 		}
 	});