From 87f7c9b7a3de0db32e9f49cd1781efe2f8300632 Mon Sep 17 00:00:00 2001 From: Thesourtimes Date: Wed, 15 Dec 2021 05:41:21 +0300 Subject: [PATCH] Make the test client togglable --- api/src/middlewares/TestClient.ts | 6 ++++-- util/src/entities/Config.ts | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/src/middlewares/TestClient.ts b/api/src/middlewares/TestClient.ts index 6167d9fde..7139b59ca 100644 --- a/api/src/middlewares/TestClient.ts +++ b/api/src/middlewares/TestClient.ts @@ -84,12 +84,14 @@ export default function TestClient(app: Application) { return res.send(buffer); }); app.get("*", (req: Request, res: Response) => { + const { useTestClient } = Config.get().client; res.set("Cache-Control", "public, max-age=" + 60 * 60 * 24); res.set("content-type", "text/html"); - if(req.url.startsWith("/api")) return; + if(req.url.startsWith("/api")) return; + if(!useTestClient) return res.send("Test client is disabled on this instance. Use a stand-alone client to connect this instance.") if (req.url.startsWith("/invite")) return res.send(html.replace("9b2b7f0632acd0c5e781", "9f24f709a3de09b67c49")); - + res.send(html); }); } \ No newline at end of file diff --git a/util/src/entities/Config.ts b/util/src/entities/Config.ts index 492baa4c2..079aa8bb3 100644 --- a/util/src/entities/Config.ts +++ b/util/src/entities/Config.ts @@ -172,6 +172,9 @@ export interface ConfigValue { allowTemplateCreation: Boolean; allowDiscordTemplates: Boolean; allowRaws: Boolean; + }, + client: { + useTestClient: Boolean; } } @@ -346,5 +349,8 @@ export const DefaultConfigOptions: ConfigValue = { allowTemplateCreation: true, allowDiscordTemplates: true, allowRaws: false + }, + client: { + useTestClient: true } };