Skip to content

Commit

Permalink
fix(default_conf): Ensure default config values for notifyText, notif…
Browse files Browse the repository at this point in the history
…yTextSize, and enableApiProxy
  • Loading branch information
andris9 committed Oct 11, 2023
1 parent d813e35 commit b7b4d9c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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');
Expand All @@ -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);
Expand Down

0 comments on commit b7b4d9c

Please sign in to comment.