Merge pull request #410 from TheArcaneBrony/master
This commit is contained in:
commit
66e2db8d88
@ -1,16 +1,18 @@
|
|||||||
import { Guild } from "@fosscord/util";
|
import { Guild, Config } from "@fosscord/util";
|
||||||
|
|
||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import { route } from "@fosscord/api";
|
import { route } from "@fosscord/api";
|
||||||
|
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
router.get("/", route({}), async (req: Request, res: Response) => {
|
router.get("/", route({}), async (req: Request, res: Response) => {
|
||||||
const { limit } = req.params;
|
const { limit } = req.params;
|
||||||
|
var showAllGuilds = Config.get().guild.showAllGuildsInDiscovery;
|
||||||
// ! this only works using SQL querys
|
// ! this only works using SQL querys
|
||||||
// TODO: implement this with default typeorm query
|
// 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: "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 || 20))}) : await Guild.find({ where: `"features" LIKE '%COMMUNITY%'`, take: Math.abs(Number(limit || 20)) });
|
||||||
res.send({ guilds: guilds });
|
res.send({ guilds: guilds });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -144,6 +144,10 @@ export interface ConfigValue {
|
|||||||
useDefaultAsOptimal: boolean;
|
useDefaultAsOptimal: boolean;
|
||||||
available: Region[];
|
available: Region[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
guild: {
|
||||||
|
showAllGuildsInDiscovery: boolean;
|
||||||
|
};
|
||||||
rabbitmq: {
|
rabbitmq: {
|
||||||
host: string | null;
|
host: string | null;
|
||||||
};
|
};
|
||||||
@ -295,6 +299,10 @@ export const DefaultConfigOptions: ConfigValue = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
guild: {
|
||||||
|
showAllGuildsInDiscovery: false,
|
||||||
|
},
|
||||||
rabbitmq: {
|
rabbitmq: {
|
||||||
host: null,
|
host: null,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user