From b1965909e69ad9021b7561d1645278f3417b8fc0 Mon Sep 17 00:00:00 2001 From: Isaac Date: Mon, 5 Sep 2022 12:52:26 +0100 Subject: [PATCH] Fix env `PUBLIC` is a path to the Public user dir on Windows, and !! does not convert a string to a boolean as expected --- package.json | 1 + scripts/preinstall.js | 2 +- src/routes/api/client.js | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ef593e2..df90d76 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "@fastify/jwt": "^5.0.1", "@fastify/oauth2": "^5.1.0", "@prisma/client": "^4.1.1", + "boolean": "^3.2.0", "cryptr": "^6.0.3", "discord.js": "^14.1.2", "dotenv": "^16.0.1", diff --git a/scripts/preinstall.js b/scripts/preinstall.js index a6cba15..5085603 100644 --- a/scripts/preinstall.js +++ b/scripts/preinstall.js @@ -10,7 +10,7 @@ const env = { HTTP_BIND: 8080, HTTP_EXTERNAL: 'http://localhost:8080', PORTAL: '', - PUBLIC: false, + PUBLIC_BOT: false, SUPER: '319467558166069248', }; diff --git a/src/routes/api/client.js b/src/routes/api/client.js index 1e8262c..40a6a60 100644 --- a/src/routes/api/client.js +++ b/src/routes/api/client.js @@ -1,4 +1,5 @@ const ms = require('ms'); +const { boolean } = require('boolean'); module.exports.get = () => ({ handler: async (req, res) => { @@ -21,7 +22,7 @@ module.exports.get = () => ({ discriminator: client.user.discriminator, id: client.user.id, portal: process.env.PORTAL || null, - public: !!process.env.PUBLIC, + public: boolean(process.env.PUBLIC_BOT), stats: { activatedUsers: users.length, archivedMessages: users.reduce((total, user) => total + user.messageCount, 0), // don't count archivedMessage table rows, they can be deleted