diff options
author | The Arcane Brony <myrainbowdash949@gmail.com> | 2021-10-01 22:11:56 +0200 |
---|---|---|
committer | The Arcane Brony <myrainbowdash949@gmail.com> | 2021-10-01 22:11:56 +0200 |
commit | 40f7e7b7d4d2c3df40c6523bc54a062eceb60737 (patch) | |
tree | b18ced670817a615004b3d2a9f101b7aaf4109ac /api | |
parent | :bug: fix disable register (diff) | |
download | server-40f7e7b7d4d2c3df40c6523bc54a062eceb60737.tar.xz |
Add setting to show all guilds in discovery, fix query for guild discovery
Diffstat (limited to 'api')
-rw-r--r-- | api/src/routes/discoverable-guilds.ts | 7 |
1 files changed, 5 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 }); }); |