summary refs log tree commit diff
path: root/api/src/routes
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/routes')
-rw-r--r--api/src/routes/guilds/#guild_id/regions.ts9
-rw-r--r--api/src/routes/voice/regions.ts11
2 files changed, 18 insertions, 2 deletions
diff --git a/api/src/routes/guilds/#guild_id/regions.ts b/api/src/routes/guilds/#guild_id/regions.ts
index 5ec649ee..212c9bcd 100644
--- a/api/src/routes/guilds/#guild_id/regions.ts
+++ b/api/src/routes/guilds/#guild_id/regions.ts
@@ -1,10 +1,15 @@
-import { Config } from "@fosscord/util";
+import {Config, Guild, Member} from "@fosscord/util";
 import { Request, Response, Router } from "express";
+import {getVoiceRegions} from "../../../util/Voice";
+import {getIpAdress} from "../../../util/ipAddress";
 
 const router = Router();
 
 router.get("/", async (req: Request, res: Response) => {
-	return res.json(Config.get().regions.available);
+	const { guild_id } = req.params;
+	const guild = await Guild.findOneOrFail({ id: guild_id });
+	//TODO we should use an enum for guild's features and not hardcoded strings
+	return res.json(await getVoiceRegions(getIpAdress(req), guild.features.includes("VIP_REGIONS")));
 });
 
 export default router;
diff --git a/api/src/routes/voice/regions.ts b/api/src/routes/voice/regions.ts
new file mode 100644
index 00000000..812aa8f6
--- /dev/null
+++ b/api/src/routes/voice/regions.ts
@@ -0,0 +1,11 @@
+import { Router, Request, Response } from "express";
+import {getIpAdress} from "../../util/ipAddress";
+import {getVoiceRegions} from "../../util/Voice";
+
+const router: Router = Router();
+
+router.get("/", async (req: Request, res: Response) => {
+    res.json(await getVoiceRegions(getIpAdress(req), true))//vip true?
+});
+
+export default router;