summary refs log tree commit diff
diff options
context:
space:
mode:
authorThe Arcane Brony <myrainbowdash949@gmail.com>2021-10-01 22:11:56 +0200
committerThe Arcane Brony <myrainbowdash949@gmail.com>2021-10-01 22:11:56 +0200
commitf3dcab6b54f7576edfdf4bd5501a59b24af0b413 (patch)
tree930ed14bb7e614f6e62a6fad8dc2146d21e12a3d
parent:bug: fix disable register (diff)
downloadserver-f3dcab6b54f7576edfdf4bd5501a59b24af0b413.tar.xz
Add setting to show all guilds in discovery, fix query for guild discovery
-rw-r--r--api/src/routes/discoverable-guilds.ts7
-rw-r--r--util/src/entities/Config.ts8
2 files changed, 13 insertions, 2 deletions
diff --git a/api/src/routes/discoverable-guilds.ts b/api/src/routes/discoverable-guilds.ts
index f667eb2a..509abc9e 100644
--- a/api/src/routes/discoverable-guilds.ts
+++ b/api/src/routes/discoverable-guilds.ts
@@ -1,16 +1,19 @@
-import { Guild } from "@fosscord/util";
+import { Guild, Config } from "@fosscord/util";
+
 import { Router, Request, Response } from "express";
 import { route } from "@fosscord/api";
 
+
 const router = Router();
 
 router.get("/", route({}), async (req: Request, res: Response) => {
 	const { limit } = req.params;
+	var showAllGuilds = Config.get().guild.showAllGuildsInDiscovery;
 
 	// ! this only works using SQL querys
 	// TODO: implement this with default typeorm query
 	// const guilds = await Guild.find({ where: { features: "DISCOVERABLE" } }); //, take: Math.abs(Number(limit)) });
-	const guilds = await Guild.find({ where: `"features" LIKE 'COMMUNITY'`, take: Math.abs(Number(limit)) });
+	const guilds = showAllGuilds ? await Guild.find({take: Math.abs(Number(limit))}) : await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit)) });
 	res.send({ guilds: guilds });
 });
 
diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts
index 8efa853c..edce92a9 100644
--- a/util/src/entities/Config.ts
+++ b/util/src/entities/Config.ts
@@ -144,6 +144,10 @@ export interface ConfigValue {
 		useDefaultAsOptimal: boolean;
 		available: Region[];
 	};
+	
+	guild: {
+		showAllGuildsInDiscovery: boolean;
+	};
 	rabbitmq: {
 		host: string | null;
 	};
@@ -295,6 +299,10 @@ export const DefaultConfigOptions: ConfigValue = {
 			},
 		],
 	},
+	
+	guild: {
+		showAllGuildsInDiscovery: false,
+	},
 	rabbitmq: {
 		host: null,
 	},