Skip to content

Commit

Permalink
fix(settings): Ensure setting service url and timezone if not set
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Dec 30, 2023
1 parent 6341400 commit 27faad9
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 95 deletions.
2 changes: 1 addition & 1 deletion data/google-crawlers.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"creationTime": "2023-12-12T23:00:40.000000",
"creationTime": "2023-12-26T23:01:00.000000",
"prefixes": [
{
"ipv6Prefix": "2001:4860:4801:2008::/64"
Expand Down
27 changes: 23 additions & 4 deletions lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ const ENCRYPTED_KEYS = [
module.exports = {
encryptedKeys: ENCRYPTED_KEYS,

async get(key) {
const encryptSecret = await getSecret();

let value = await redis.hget(`${REDIS_PREFIX}settings`, key);
async getValue(encryptSecret, key, value) {
if (!value) {
return null;
}
Expand Down Expand Up @@ -77,6 +74,28 @@ module.exports = {
return value;
},

async getMulti(...keys) {
const encryptSecret = await getSecret();

let values = await redis.hmget(`${REDIS_PREFIX}settings`, keys);
let result = {};
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
let value = values[i];
result[key] = await this.getValue(encryptSecret, key, value);
}

return result;
},

async get(key) {
const encryptSecret = await getSecret();

let value = await redis.hget(`${REDIS_PREFIX}settings`, key);

return await this.getValue(encryptSecret, key, value);
},

formatSettingValue(key, value) {
switch (key) {
case 'scriptEnv':
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"main": "server.js",
"scripts": {
"start": "node server.js",
"dev": "EE_OPENAPI_VERBOSE=true EENGINE_LOG_RAW=true node --tls-keylog=keylog.txt server --dbs.redis='redis://127.0.0.1:6379/9' --api.port=7003 --api.host=0.0.0.0 | tee $HOME/dev.txt | pino-pretty",
"single": "EE_OPENAPI_VERBOSE=true EENGINE_LOG_RAW=false EENGINE_WORKERS=1 node --inspect server --dbs.redis='redis://127.0.0.1:6379/10' --api.port=7009 --api.host=0.0.0.0 | tee $HOME/log.txt | pino-pretty",
"raw": "NODE_OPTIONS=--no-experimental-fetch EENGINE_LOG_RAW=true node server --dbs.redis='redis://127.0.0.1:6379/9' | eerawlog",
"dev": "EE_OPENAPI_VERBOSE=true EENGINE_LOG_RAW=true node --tls-keylog=keylog.txt server --dbs.redis='redis://127.0.0.1:6379/9' --api.port=7003 --api.host=0.0.0.0 | tee $HOME/ee.log.dev.txt | pino-pretty",
"single": "EE_OPENAPI_VERBOSE=true EENGINE_LOG_RAW=true EENGINE_WORKERS=1 node --inspect server --dbs.redis='redis://127.0.0.1:6379/10' --api.port=7009 --api.host=0.0.0.0 | tee $HOME/ee.log.single.txt | pino-pretty",
"gmail": "EE_OPENAPI_VERBOSE=true EENGINE_LOG_RAW=true EENGINE_FEATURE_GMAIL_API=true EENGINE_WORKERS=1 node --inspect server --dbs.redis='redis://127.0.0.1:6379/11' --api.port=7003 --api.host=0.0.0.0 | tee $HOME/ee.log.gmail.txt | pino-pretty",
"test": "grunt && node --test test/",
"swagger": "./getswagger.sh",
"build-source": "rm -rf node_modules && npm install && rm -rf node_modules && npm install --omit=dev && ./update-info.sh",
Expand Down Expand Up @@ -54,10 +54,10 @@
"@postalsys/email-text-tools": "2.1.3",
"@postalsys/hecks": "3.0.0-fork.3",
"@postalsys/templates": "1.0.7",
"ace-builds": "1.32.2",
"ace-builds": "1.32.3",
"base32.js": "0.1.0",
"bull-arena": "4.1.0",
"bullmq": "4.16.0",
"bullmq": "5.1.0",
"compare-versions": "6.1.0",
"dotenv": "16.3.1",
"encoding-japanese": "2.0.0",
Expand Down Expand Up @@ -93,7 +93,7 @@
"nanoid": "3.3.4",
"node-gettext": "3.0.0",
"nodemailer": "6.9.7",
"pino": "8.17.1",
"pino": "8.17.2",
"prom-client": "15.1.0",
"psl": "1.9.0",
"pubface": "1.0.6",
Expand All @@ -110,7 +110,7 @@
"xml2js": "0.6.2"
},
"devDependencies": {
"chai": "4.3.10",
"chai": "5.0.0",
"eerawlog": "1.5.1",
"eslint": "8.56.0",
"eslint-config-nodemailer": "1.2.0",
Expand All @@ -119,7 +119,7 @@
"grunt-cli": "1.4.3",
"grunt-eslint": "24.3.0",
"jsxgettext": "0.11.0",
"pino-pretty": "10.3.0",
"pino-pretty": "10.3.1",
"pkg": "5.8.1",
"resedit": "2.0.0",
"xgettext-template": "5.0.0"
Expand Down
2 changes: 1 addition & 1 deletion sbom.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/js/ace/ace.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/js/ace/ext-language_tools.js

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions static/licenses.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/@babel/runtime">@babel/runtime</a></td>
<td>7.23.6</td>
<td>7.23.7</td>
<td>MIT</td>
<td>The Babel Team</td>
<td></td>
Expand Down Expand Up @@ -1136,7 +1136,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/ace-builds">ace-builds</a></td>
<td>1.32.2</td>
<td>1.32.3</td>
<td>BSD-3-Clause</td>
<td></td>
<td></td>
Expand Down Expand Up @@ -1186,7 +1186,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/acorn">acorn</a></td>
<td>8.11.2</td>
<td>8.11.3</td>
<td>MIT</td>
<td></td>
<td></td>
Expand Down Expand Up @@ -1386,7 +1386,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/assertion-error">assertion-error</a></td>
<td>1.1.0</td>
<td>2.0.1</td>
<td>MIT</td>
<td>Jake Luer</td>
<td>jake@qualiancy.com</td>
Expand Down Expand Up @@ -1616,7 +1616,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/bullmq">bullmq</a></td>
<td>4.16.0</td>
<td>5.1.0</td>
<td>MIT</td>
<td>Taskforce.sh Inc.</td>
<td></td>
Expand Down Expand Up @@ -1696,7 +1696,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/chai">chai</a></td>
<td>4.3.10</td>
<td>5.0.0</td>
<td>MIT</td>
<td>Jake Luer</td>
<td>jake@alogicalparadox.com</td>
Expand Down Expand Up @@ -1736,7 +1736,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/check-error">check-error</a></td>
<td>1.0.3</td>
<td>2.0.0</td>
<td>MIT</td>
<td>Jake Luer</td>
<td>jake@alogicalparadox.com</td>
Expand Down Expand Up @@ -2186,7 +2186,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/deep-eql">deep-eql</a></td>
<td>4.1.3</td>
<td>5.0.1</td>
<td>MIT</td>
<td>Jake Luer</td>
<td>jake@alogicalparadox.com</td>
Expand Down Expand Up @@ -4635,7 +4635,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/loupe">loupe</a></td>
<td>2.3.7</td>
<td>3.0.2</td>
<td>MIT</td>
<td>Veselin Todorov</td>
<td>hi@vesln.com</td>
Expand Down Expand Up @@ -5385,7 +5385,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/msgpackr">msgpackr</a></td>
<td>1.10.0</td>
<td>1.10.1</td>
<td>MIT</td>
<td>Kris Zyp</td>
<td></td>
Expand Down Expand Up @@ -6035,7 +6035,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/pathval">pathval</a></td>
<td>1.1.1</td>
<td>2.0.0</td>
<td>MIT</td>
<td>Veselin Todorov</td>
<td>hi@vesln.com</td>
Expand Down Expand Up @@ -6095,7 +6095,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/pino-pretty">pino-pretty</a></td>
<td>10.3.0</td>
<td>10.3.1</td>
<td>MIT</td>
<td>James Sumners</td>
<td>james.sumners@gmail.com</td>
Expand Down Expand Up @@ -6125,7 +6125,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/pino">pino</a></td>
<td>8.17.1</td>
<td>8.17.2</td>
<td>MIT</td>
<td>Matteo Collina</td>
<td>hello@matteocollina.com</td>
Expand Down Expand Up @@ -6204,6 +6204,16 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</td
</tr>
<tr>
<td><a href="https://npmjs.com/package/process-warning">process-warning</a></td>
<td>3.0.0</td>
<td>MIT</td>
<td>Tomas Della Vedova</td>
<td></td>
<td>
<a href="https://github.com/fastify/process-warning">github.com/fastify/process-warning</a>
</td
</tr>
<tr>
<td><a href="https://npmjs.com/package/process">process</a></td>
<td>0.11.10</td>
<td>MIT</td>
Expand Down Expand Up @@ -6455,7 +6465,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/readable-stream">readable-stream</a></td>
<td>4.5.1</td>
<td>4.5.2</td>
<td>MIT</td>
<td></td>
<td></td>
Expand Down Expand Up @@ -7494,16 +7504,6 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</td
</tr>
<tr>
<td><a href="https://npmjs.com/package/type-detect">type-detect</a></td>
<td>4.0.8</td>
<td>MIT</td>
<td>Jake Luer</td>
<td>jake@alogicalparadox.com</td>
<td>
<a href="https://github.com/chaijs/type-detect">github.com/chaijs/type-detect</a>
</td
</tr>
<tr>
<td><a href="https://npmjs.com/package/type-fest">type-fest</a></td>
<td>0.20.2</td>
<td>(MIT OR CC0-1.0)</td>
Expand Down Expand Up @@ -7925,7 +7925,7 @@ <h1>EmailEngine v2.39.4</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/ws">ws</a></td>
<td>8.15.1</td>
<td>8.16.0</td>
<td>MIT</td>
<td>Einar Otto Stangvik</td>
<td>einaros@gmail.com</td>
Expand Down
18 changes: 9 additions & 9 deletions translations/messages.pot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=ascii\n"
"POT-Creation-Date: 2023-12-19 11:03+0000\n"
"POT-Creation-Date: 2023-12-30 08:16+0000\n"

#: views/config/license.hbs:48
msgid "%d day"
Expand Down Expand Up @@ -80,6 +80,14 @@ msgstr ""
msgid "Continue"
msgstr ""

#: views/accounts/register/index.hbs:2
msgid "Choose your email account provider"
msgstr ""

#: views/accounts/register/index.hbs:15
msgid "Standard IMAP"
msgstr ""

#: views/accounts/register/imap-server.hbs:18
msgid "IMAP"
msgstr ""
Expand Down Expand Up @@ -181,14 +189,6 @@ msgstr ""
msgid "HTTP error!"
msgstr ""

#: views/accounts/register/index.hbs:2
msgid "Choose your email account provider"
msgstr ""

#: views/accounts/register/index.hbs:15
msgid "Standard IMAP"
msgstr ""

#: lib/routes-ui.js:601
msgid "Invalid API key for OpenAI"
msgstr ""
Expand Down
33 changes: 0 additions & 33 deletions views/dashboard.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -305,38 +305,5 @@
</div>

<input type="hidden" name="crumb" id="crumb" value="{{crumb}}" />
<script>
document.addEventListener('DOMContentLoaded', () => {
let sendBrowserInfo = async () => {
let timezone = false;
try {
timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
} catch (err) {
console.error(err);
}
try {
const res = await fetch('/admin/config/browser', {
method: 'post',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
crumb: document.getElementById('crumb').value,
serviceUrl: window.location.origin || false,
timezone: timezone || false,
language: navigator.language || false
})
});
if (!res.ok) {
console.error('Failed to post browser info');
}
} catch (err) {
console.error(err);
}
}
sendBrowserInfo().catch(err => console.error(err))
});
</script>

{{>add_account_modal}}
43 changes: 43 additions & 0 deletions views/layout/app.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,49 @@
</script>

{{/if}}

{{#if updateBrowserInfo}}
<input type="hidden" id="browser-info-crumb" value="{{crumb}}" />
<script>
document.addEventListener('DOMContentLoaded', () => {
let sendBrowserInfo = async () => {
let timezone = false;
try {
timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
} catch (err) {
console.error(err);
}
try {
const res = await fetch('/admin/config/browser', {
method: 'post',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
crumb: document.getElementById('browser-info-crumb').value,
serviceUrl: window.location.origin || false,
timezone: timezone || false,
language: navigator.language || false
})
});
if (!res.ok) {
console.error('Failed to post browser info');
} else {
let serviceUrlformEntry = document.querySelector('#settingsServiceUrl')
if (serviceUrlformEntry && !serviceUrlformEntry.value) {
serviceUrlformEntry.value = window.location.origin || ''
}
}
} catch (err) {
console.error(err);
}
}
sendBrowserInfo().catch(err => console.error(err))
});
</script>
{{/if}}
</body>

</html>
Loading

0 comments on commit 27faad9

Please sign in to comment.