mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 20:52:42 +01:00
Add setting to show all guilds in discovery, fix query for guild discovery
This commit is contained in:
parent
00e3fde177
commit
40f7e7b7d4
@ -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 });
|
||||
});
|
||||
|
||||
|
@ -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,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user