summary refs log tree commit diff
path: root/api/src
diff options
context:
space:
mode:
authorThesourtimes <cckhmck@gmail.com>2021-12-15 05:46:10 +0300
committerThesourtimes <cckhmck@gmail.com>2021-12-15 05:46:10 +0300
commit0d16ae1da40b7d8b2619c6c5ae79ff9cd3c8c5c3 (patch)
tree51798597743af7cfceccf5441dff3692fbe3643f /api/src
parentMake the test client togglable (diff)
downloadserver-0d16ae1da40b7d8b2619c6c5ae79ff9cd3c8c5c3.tar.xz
Add the new discovery route
Diffstat (limited to 'api/src')
-rw-r--r--api/src/routes/guild-recommendations.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/api/src/routes/guild-recommendations.ts b/api/src/routes/guild-recommendations.ts
new file mode 100644

index 00000000..503b19b7 --- /dev/null +++ b/api/src/routes/guild-recommendations.ts
@@ -0,0 +1,20 @@ +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, personalization_disabled } = 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 = showAllGuilds + ? await Guild.find({ take: Math.abs(Number(limit || 20)) }) + : await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 100)) }); + res.send({ recommended_guilds: guilds }); +}); + +export default router;