Skip to content

Commit

Permalink
fix(imap): Allow to define IMAP TCP socket timeout with the EENGINE_I…
Browse files Browse the repository at this point in the history
…MAP_SOCKET_TIMEOUT env value
  • Loading branch information
andris9 committed Nov 24, 2023
1 parent d939955 commit 4d29d20
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 48 deletions.
11 changes: 10 additions & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const {
getByteSize,
getBoolean,
readEnvValue,
validUidValidity
validUidValidity,
getDuration
} = require('./tools');

const RESYNC_DELAY = 15 * 60;
Expand All @@ -66,6 +67,9 @@ const {

const DOWNLOAD_CHUNK_SIZE = getByteSize(readEnvValue('EENGINE_CHUNK_SIZE')) || DEFAULT_DOWNLOAD_CHUNK_SIZE;
const DISABLE_IMAP_COMPRESSION = getBoolean(readEnvValue('EENGINE_DISABLE_COMPRESSION'));
const IMAP_SOCKET_TIMEOUT = getDuration(readEnvValue('EENGINE_IMAP_SOCKET_TIMEOUT'));

logger.trace({ msg: 'Worker configuration', DOWNLOAD_CHUNK_SIZE, DISABLE_IMAP_COMPRESSION, IMAP_SOCKET_TIMEOUT });

const settings = require('./settings');
const { redis } = require('./db');
Expand Down Expand Up @@ -990,6 +994,7 @@ class Connection {
// Special case for Yahoo. Break IDLE at least once every three minutes
imapConfig.maxIdleTime = 3 * 60 * 1000;
}

/*
else if (/(\.naver\.com)$/i.test(imapConfig.host)) {
// NOOP does nothing in Naver, must run SELECT for changes in the folder to apply
Expand All @@ -1002,6 +1007,10 @@ class Connection {
imapConfig.disableCompression = true;
}

if (IMAP_SOCKET_TIMEOUT) {
imapConfig.socketTimeout = IMAP_SOCKET_TIMEOUT;
}

const ignoreMailCertErrors = await settings.get('ignoreMailCertErrors');
if (ignoreMailCertErrors && imapConfig?.tls?.rejectUnauthorized !== false) {
imapConfig.tls = imapConfig.tls || {};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"ace-builds": "1.31.2",
"base32.js": "0.1.0",
"bull-arena": "4.1.0",
"bullmq": "4.14.0",
"bullmq": "4.14.1",
"compare-versions": "6.1.0",
"dotenv": "16.3.1",
"encoding-japanese": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sbom.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions static/licenses.html
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ <h1>EmailEngine v2.39.0</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/bullmq">bullmq</a></td>
<td>4.14.0</td>
<td>4.14.1</td>
<td>MIT</td>
<td>Taskforce.sh Inc.</td>
<td></td>
Expand Down Expand Up @@ -4655,7 +4655,7 @@ <h1>EmailEngine v2.39.0</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/lru-cache">lru-cache</a></td>
<td>10.0.3</td>
<td>10.1.0</td>
<td>ISC</td>
<td>Isaac Z. Schlueter</td>
<td>[email protected]</td>
Expand Down Expand Up @@ -7235,7 +7235,7 @@ <h1>EmailEngine v2.39.0</h1><p>EmailEngine includes code from the following soft
</tr>
<tr>
<td><a href="https://npmjs.com/package/swagger-ui-dist">swagger-ui-dist</a></td>
<td>5.10.2</td>
<td>5.10.3</td>
<td>Apache-2.0</td>
<td></td>
<td></td>
Expand Down
84 changes: 42 additions & 42 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-11-22 08:44+0000\n"
"POT-Creation-Date: 2023-11-24 07:38+0000\n"

#: views/config/license.hbs:48
msgid "%d day"
Expand All @@ -13,47 +13,6 @@ msgstr[1] ""
msgid "Click <a href=\"%s\">here</a> to continue&mldr;"
msgstr ""

#: views/accounts/register/imap.hbs:11
msgid "Your name"
msgstr ""

#: views/accounts/register/imap.hbs:17
msgid "Enter your full name"
msgstr ""

#: views/accounts/register/imap.hbs:21
#: views/unsubscribe.hbs:69
msgid "Email address"
msgstr ""

#: views/accounts/register/imap.hbs:27
#: views/unsubscribe.hbs:75
msgid "Enter your email address"
msgstr ""

#: views/accounts/register/imap.hbs:31
#: views/accounts/register/imap-server.hbs:35
#: views/accounts/register/imap-server.hbs:114
msgid "Password"
msgstr ""

#: views/accounts/register/imap.hbs:37
msgid "Enter your account password"
msgstr ""

#: views/accounts/register/imap.hbs:51
#: views/accounts/register/imap-server.hbs:192
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/unsubscribe.hbs:1
#: views/unsubscribe.hbs:79
msgid "Unsubscribe"
Expand Down Expand Up @@ -88,6 +47,47 @@ msgstr ""
msgid "Your email address <em>%s</em> was re-subscribed."
msgstr ""

#: views/unsubscribe.hbs:69
#: views/accounts/register/imap.hbs:21
msgid "Email address"
msgstr ""

#: views/unsubscribe.hbs:75
#: views/accounts/register/imap.hbs:27
msgid "Enter your email address"
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.hbs:11
msgid "Your name"
msgstr ""

#: views/accounts/register/imap.hbs:17
msgid "Enter your full name"
msgstr ""

#: views/accounts/register/imap.hbs:31
#: views/accounts/register/imap-server.hbs:35
#: views/accounts/register/imap-server.hbs:114
msgid "Password"
msgstr ""

#: views/accounts/register/imap.hbs:37
msgid "Enter your account password"
msgstr ""

#: views/accounts/register/imap.hbs:51
#: views/accounts/register/imap-server.hbs:192
msgid "Continue"
msgstr ""

#: views/accounts/register/imap-server.hbs:18
msgid "IMAP"
msgstr ""
Expand Down

0 comments on commit 4d29d20

Please sign in to comment.