diff options
author | Featyre <twooter.0g179@simplelogin.co> | 2022-01-24 07:21:48 +0000 |
---|---|---|
committer | Featyre <twooter.0g179@simplelogin.co> | 2022-01-24 07:21:48 +0000 |
commit | e3f20f849d089493328314ad7d7518eaea3d862a (patch) | |
tree | 294774d318a7baf80f271e71a4346d26523f432d /api | |
parent | Merge branch 'fosscord:master' into master (diff) | |
download | server-e3f20f849d089493328314ad7d7518eaea3d862a.tar.xz |
category + discovery + custom status fix, new config
Diffstat (limited to 'api')
-rw-r--r-- | api/assets/fosscord-login.css | 1 | ||||
-rw-r--r-- | api/src/routes/discoverable-guilds.ts | 29 | ||||
-rw-r--r-- | api/src/routes/discovery.ts (renamed from api/src/routes/categories.ts) | 4 | ||||
-rw-r--r-- | api/src/routes/guild-recommendations.ts | 2 |
4 files changed, 19 insertions, 17 deletions
diff --git a/api/assets/fosscord-login.css b/api/assets/fosscord-login.css index 34cf542b..d507c545 100644 --- a/api/assets/fosscord-login.css +++ b/api/assets/fosscord-login.css @@ -26,7 +26,6 @@ h3.title-jXR8lp.marginBottom8-AtZOdT.base-1x0h_U.size24-RIRrxO::after { width: 130px; height: 23px; background-size: contain; - border-radius: 50%; } /* replace TOS text */ diff --git a/api/src/routes/discoverable-guilds.ts b/api/src/routes/discoverable-guilds.ts index a4559b59..8b7d343f 100644 --- a/api/src/routes/discoverable-guilds.ts +++ b/api/src/routes/discoverable-guilds.ts @@ -6,26 +6,29 @@ import { route } from "@fosscord/api"; const router = Router(); router.get("/", route({}), async (req: Request, res: Response) => { - const { limit, categories } = req.query; - var showAllGuilds = Config.get().guild.showAllGuildsInDiscovery; + const { offset, limit, categories } = req.query; + var showAllGuilds = Config.get().guild.discovery.showAllGuilds; + var configLimit = Config.get().guild.discovery.limit; // ! 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)) }); let guilds; let total; - switch (categories) { - case "1": - guilds = showAllGuilds - ? await Guild.find({ take: Math.abs(Number(limit || 24)) }) - : await Guild.find({ where: `"primary_category_id" = 1 AND "features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 24)) }); - total = guilds.length; - default: - guilds = showAllGuilds - ? await Guild.find({ take: Math.abs(Number(limit || 24)) }) - : await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 24)) }); + if (categories == undefined) { + guilds = showAllGuilds + ? await Guild.find({ take: Math.abs(Number(limit || configLimit)) }) + : await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || configLimit)) }); + total = guilds.length; + } else { + guilds = showAllGuilds + ? await Guild.find({ where: `"primary_category_id" = ${categories}`, take: Math.abs(Number(limit || configLimit)) }) + : await Guild.find({ + where: `"primary_category_id" = ${categories} AND "features" LIKE '%COMMUNITY%'`, + take: Math.abs(Number(limit || configLimit)) + }); total = guilds.length; } - res.send({ total: total, guilds: guilds, offset: 0, limit: limit}); + res.send({ total: total, guilds: guilds, offset: Number(offset || Config.get().guild.discovery.offset), limit: Number(limit || configLimit) }); }); export default router; diff --git a/api/src/routes/categories.ts b/api/src/routes/discovery.ts index 58322676..067dd442 100644 --- a/api/src/routes/categories.ts +++ b/api/src/routes/discovery.ts @@ -3,7 +3,7 @@ import { route } from "@fosscord/api"; const router = Router(); -router.get("/", route({}), (req: Request, res: Response) => { +router.get("/categories", route({}), (req: Request, res: Response) => { // TODO: // Load categories from db instead @@ -21,7 +21,7 @@ router.get("/", route({}), (req: Request, res: Response) => { } } - res.json(out).status(200); + res.send(out); }); export default router; diff --git a/api/src/routes/guild-recommendations.ts b/api/src/routes/guild-recommendations.ts index 47017a6f..ecc5e546 100644 --- a/api/src/routes/guild-recommendations.ts +++ b/api/src/routes/guild-recommendations.ts @@ -7,7 +7,7 @@ const router = Router(); router.get("/", route({}), async (req: Request, res: Response) => { const { limit, personalization_disabled } = req.query; - var showAllGuilds = Config.get().guild.showAllGuildsInDiscovery; + var showAllGuilds = Config.get().guild.discovery.showAllGuilds; // ! 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)) }); |