From b7b4d9c150ffabd533e5015b2e4aee4f26160b30 Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Wed, 11 Oct 2023 10:51:22 +0300 Subject: [PATCH] fix(default_conf): Ensure default config values for notifyText, notifyTextSize, and enableApiProxy --- server.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index 2edb6394..3e73b0eb 100644 --- a/server.js +++ b/server.js @@ -190,6 +190,7 @@ const IMAP_PROXY_PROXY = hasEnvValue('EENGINE_IMAP_PROXY_PROXY') ? getBoolean(readEnvValue('EENGINE_IMAP_PROXY_PROXY')) : getBoolean(config['imap-proxy'].proxy); +const HAS_API_PROXY_SET = hasEnvValue('EENGINE_API_PROXY') || typeof config.api.proxy !== 'undefined'; const API_PROXY = hasEnvValue('EENGINE_API_PROXY') ? getBoolean(readEnvValue('EENGINE_API_PROXY')) : getBoolean(config.api.proxy); logger.info({ @@ -1965,7 +1966,7 @@ const startApplication = async () => { let existingEnableApiProxy = await settings.get('enableApiProxy'); if (existingEnableApiProxy === null) { - await settings.set('enableApiProxy', API_PROXY); + await settings.set('enableApiProxy', HAS_API_PROXY_SET ? API_PROXY : true); } let existingServiceSecret = await settings.get('serviceSecret'); @@ -1979,6 +1980,21 @@ const startApplication = async () => { await settings.set('queueKeep', QUEUE_KEEP); } + let existingNotifyText = await settings.get('notifyText'); + if (existingNotifyText === null) { + await settings.set('notifyText', true); + } + + let existingNotifyTextSize = await settings.get('notifyTextSize'); + if (existingNotifyTextSize === null) { + await settings.set('notifyTextSize', 2 * 1024 * 1024); // set default max text size in webhooks to 2MB + } + + let existingScriptEnv = await settings.get('scriptEnv'); + if (existingScriptEnv === null) { + await settings.set('scriptEnv', {}); // empty object + } + if (preparedToken) { try { let imported = await tokens.setRawData(preparedToken);