emailengine-app 2.74.1 → 2.74.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/data/google-crawlers.json +1 -1
- package/lib/account.js +23 -45
- package/lib/api-routes/changes-routes.js +51 -0
- package/lib/api-routes/index.js +160 -0
- package/lib/consts.js +15 -0
- package/lib/email-client/gmail/send-request.js +69 -0
- package/lib/email-client/gmail-client.js +4 -41
- package/lib/email-client/imap/detach-client.js +27 -0
- package/lib/email-client/imap/listing-diff.js +165 -0
- package/lib/email-client/imap/mailbox.js +32 -13
- package/lib/email-client/imap/subconnection.js +2 -4
- package/lib/email-client/imap/sync-operations.js +5 -3
- package/lib/email-client/imap-client.js +50 -84
- package/lib/email-client/outlook/send-request.js +48 -0
- package/lib/email-client/outlook-client.js +5 -14
- package/lib/export.js +97 -21
- package/lib/imapproxy/imap-core/lib/imap-connection.js +1 -1
- package/lib/logger.js +14 -6
- package/lib/rate-limit.js +33 -11
- package/lib/response-stream.js +138 -0
- package/lib/sentry.js +8 -0
- package/lib/smtp-message-processor.js +131 -0
- package/lib/tools.js +28 -5
- package/lib/ui-routes/internals-routes.js +32 -0
- package/package.json +6 -6
- package/sbom.json +1 -1
- package/static/licenses.html +22 -12
- package/translations/messages.pot +35 -35
- package/views/internals/index.hbs +8 -0
- package/workers/api.js +20 -216
- package/workers/export.js +29 -15
- package/workers/imap.js +47 -10
- package/workers/smtp.js +50 -91
package/static/licenses.html
CHANGED
|
@@ -29,7 +29,7 @@ pre { background: var(--bg); border-radius: 0.5rem; padding: 1rem; overflow-x: a
|
|
|
29
29
|
</head>
|
|
30
30
|
<body>
|
|
31
31
|
<main>
|
|
32
|
-
<h1>EmailEngine v2.74.
|
|
32
|
+
<h1>EmailEngine v2.74.1</h1>
|
|
33
33
|
<p class="intro">EmailEngine includes code from the following open source packages. Entries marked <em>asset</em> are build-time packages whose output is embedded in the UI assets, or bundled fonts and scripts.</p>
|
|
34
34
|
<ul>
|
|
35
35
|
<li class="package">
|
|
@@ -335,7 +335,7 @@ THE SOFTWARE.</pre></details>
|
|
|
335
335
|
<li class="package">
|
|
336
336
|
<div class="head">
|
|
337
337
|
<span class="name">@apm-js-collab/code-transformer-bundler-plugins</span>
|
|
338
|
-
<span class="version">0.7.
|
|
338
|
+
<span class="version">0.7.1</span>
|
|
339
339
|
<span class="badge">MIT</span>
|
|
340
340
|
<span class="badge badge-runtime">runtime</span>
|
|
341
341
|
<span class="links"><a href="https://npmjs.com/package/@apm-js-collab/code-transformer-bundler-plugins" rel="noopener noreferrer">npm</a> <a href="https://github.com/apm-js-collab/code-transformer-bundler-plugins" rel="noopener noreferrer">website</a></span>
|
|
@@ -3610,7 +3610,7 @@ SOFTWARE.</pre></details>
|
|
|
3610
3610
|
<li class="package">
|
|
3611
3611
|
<div class="head">
|
|
3612
3612
|
<span class="name">@sentry/core</span>
|
|
3613
|
-
<span class="version">10.
|
|
3613
|
+
<span class="version">10.68.0</span>
|
|
3614
3614
|
<span class="badge">MIT</span>
|
|
3615
3615
|
<span class="badge badge-runtime">runtime</span>
|
|
3616
3616
|
<span class="links"><a href="https://npmjs.com/package/@sentry/core" rel="noopener noreferrer">npm</a> <a href="https://github.com/getsentry/sentry-javascript/tree/master/packages/core" rel="noopener noreferrer">website</a></span>
|
|
@@ -3640,7 +3640,7 @@ SOFTWARE.</pre></details>
|
|
|
3640
3640
|
<li class="package">
|
|
3641
3641
|
<div class="head">
|
|
3642
3642
|
<span class="name">@sentry/node</span>
|
|
3643
|
-
<span class="version">10.
|
|
3643
|
+
<span class="version">10.68.0</span>
|
|
3644
3644
|
<span class="badge">MIT</span>
|
|
3645
3645
|
<span class="badge badge-runtime">runtime</span>
|
|
3646
3646
|
<span class="links"><a href="https://npmjs.com/package/@sentry/node" rel="noopener noreferrer">npm</a> <a href="https://github.com/getsentry/sentry-javascript/tree/master/packages/node" rel="noopener noreferrer">website</a></span>
|
|
@@ -3670,7 +3670,7 @@ SOFTWARE.</pre></details>
|
|
|
3670
3670
|
<li class="package">
|
|
3671
3671
|
<div class="head">
|
|
3672
3672
|
<span class="name">@sentry/node-core</span>
|
|
3673
|
-
<span class="version">10.
|
|
3673
|
+
<span class="version">10.68.0</span>
|
|
3674
3674
|
<span class="badge">MIT</span>
|
|
3675
3675
|
<span class="badge badge-runtime">runtime</span>
|
|
3676
3676
|
<span class="links"><a href="https://npmjs.com/package/@sentry/node-core" rel="noopener noreferrer">npm</a> <a href="https://github.com/getsentry/sentry-javascript/tree/master/packages/node-core" rel="noopener noreferrer">website</a></span>
|
|
@@ -3700,7 +3700,7 @@ SOFTWARE.</pre></details>
|
|
|
3700
3700
|
<li class="package">
|
|
3701
3701
|
<div class="head">
|
|
3702
3702
|
<span class="name">@sentry/opentelemetry</span>
|
|
3703
|
-
<span class="version">10.
|
|
3703
|
+
<span class="version">10.68.0</span>
|
|
3704
3704
|
<span class="badge">MIT</span>
|
|
3705
3705
|
<span class="badge badge-runtime">runtime</span>
|
|
3706
3706
|
<span class="links"><a href="https://npmjs.com/package/@sentry/opentelemetry" rel="noopener noreferrer">npm</a> <a href="https://github.com/getsentry/sentry-javascript/tree/master/packages/opentelemetry" rel="noopener noreferrer">website</a></span>
|
|
@@ -3710,7 +3710,7 @@ SOFTWARE.</pre></details>
|
|
|
3710
3710
|
<li class="package">
|
|
3711
3711
|
<div class="head">
|
|
3712
3712
|
<span class="name">@sentry/server-utils</span>
|
|
3713
|
-
<span class="version">10.
|
|
3713
|
+
<span class="version">10.68.0</span>
|
|
3714
3714
|
<span class="badge">MIT</span>
|
|
3715
3715
|
<span class="badge badge-runtime">runtime</span>
|
|
3716
3716
|
<span class="links"><a href="https://npmjs.com/package/@sentry/server-utils" rel="noopener noreferrer">npm</a> <a href="https://github.com/getsentry/sentry-javascript/tree/master/packages/server-utils" rel="noopener noreferrer">website</a></span>
|
|
@@ -4893,7 +4893,7 @@ THE SOFTWARE.</pre></details>
|
|
|
4893
4893
|
<li class="package">
|
|
4894
4894
|
<div class="head">
|
|
4895
4895
|
<span class="name">bullmq</span>
|
|
4896
|
-
<span class="version">5.81.
|
|
4896
|
+
<span class="version">5.81.2</span>
|
|
4897
4897
|
<span class="badge">MIT</span>
|
|
4898
4898
|
<span class="badge badge-runtime">runtime</span>
|
|
4899
4899
|
<span class="links"><a href="https://npmjs.com/package/bullmq" rel="noopener noreferrer">npm</a> <a href="https://bullmq.io/" rel="noopener noreferrer">website</a></span>
|
|
@@ -7679,7 +7679,7 @@ SOFTWARE.</pre></details>
|
|
|
7679
7679
|
<li class="package">
|
|
7680
7680
|
<div class="head">
|
|
7681
7681
|
<span class="name">ip-address</span>
|
|
7682
|
-
<span class="version">10.
|
|
7682
|
+
<span class="version">10.3.1</span>
|
|
7683
7683
|
<span class="badge">MIT</span>
|
|
7684
7684
|
<span class="badge badge-runtime">runtime</span>
|
|
7685
7685
|
<span class="links"><a href="https://npmjs.com/package/ip-address" rel="noopener noreferrer">npm</a> <a href="https://github.com/beaugunderson/ip-address" rel="noopener noreferrer">website</a></span>
|
|
@@ -10469,7 +10469,7 @@ SOFTWARE.</pre></details>
|
|
|
10469
10469
|
<li class="package">
|
|
10470
10470
|
<div class="head">
|
|
10471
10471
|
<span class="name">sax</span>
|
|
10472
|
-
<span class="version">1.6.
|
|
10472
|
+
<span class="version">1.6.1</span>
|
|
10473
10473
|
<span class="badge">BlueOak-1.0.0</span>
|
|
10474
10474
|
<span class="badge badge-runtime">runtime</span>
|
|
10475
10475
|
<span class="links"><a href="https://npmjs.com/package/sax" rel="noopener noreferrer">npm</a> <a href="https://github.com/isaacs/sax-js" rel="noopener noreferrer">website</a></span>
|
|
@@ -11326,7 +11326,7 @@ SUCH DAMAGE.</pre></details>
|
|
|
11326
11326
|
<li class="package">
|
|
11327
11327
|
<div class="head">
|
|
11328
11328
|
<span class="name">undici</span>
|
|
11329
|
-
<span class="version">7.
|
|
11329
|
+
<span class="version">7.29.0</span>
|
|
11330
11330
|
<span class="badge">MIT</span>
|
|
11331
11331
|
<span class="badge badge-runtime">runtime</span>
|
|
11332
11332
|
<span class="links"><a href="https://npmjs.com/package/undici" rel="noopener noreferrer">npm</a> <a href="https://undici.nodejs.org" rel="noopener noreferrer">website</a></span>
|
|
@@ -11356,7 +11356,17 @@ SOFTWARE.</pre></details>
|
|
|
11356
11356
|
<li class="package">
|
|
11357
11357
|
<div class="head">
|
|
11358
11358
|
<span class="name">undici</span>
|
|
11359
|
-
<span class="version">
|
|
11359
|
+
<span class="version">7.28.0</span>
|
|
11360
|
+
<span class="badge">MIT</span>
|
|
11361
|
+
<span class="badge badge-runtime">runtime</span>
|
|
11362
|
+
<span class="links"><a href="https://npmjs.com/package/undici" rel="noopener noreferrer">npm</a> <a href="https://undici.nodejs.org" rel="noopener noreferrer">website</a></span>
|
|
11363
|
+
</div>
|
|
11364
|
+
<p class="no-text">Same license text as <a href="#lic-237">undici</a>.</p>
|
|
11365
|
+
</li>
|
|
11366
|
+
<li class="package">
|
|
11367
|
+
<div class="head">
|
|
11368
|
+
<span class="name">undici</span>
|
|
11369
|
+
<span class="version">6.28.0</span>
|
|
11360
11370
|
<span class="badge">MIT</span>
|
|
11361
11371
|
<span class="badge badge-runtime">runtime</span>
|
|
11362
11372
|
<span class="links"><a href="https://npmjs.com/package/undici" rel="noopener noreferrer">npm</a> <a href="https://undici.nodejs.org" rel="noopener noreferrer">website</a></span>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
msgid ""
|
|
2
2
|
msgstr ""
|
|
3
3
|
"Content-Type: text/plain; charset=ascii\n"
|
|
4
|
-
"POT-Creation-Date: 2026-07-
|
|
4
|
+
"POT-Creation-Date: 2026-07-26 05:20+0000\n"
|
|
5
5
|
|
|
6
6
|
#: views/error.hbs:6
|
|
7
|
-
#: workers/api.js:
|
|
7
|
+
#: workers/api.js:3019
|
|
8
8
|
msgid "Something went wrong"
|
|
9
9
|
msgstr ""
|
|
10
10
|
|
|
@@ -27,30 +27,6 @@ msgid_plural "%d days"
|
|
|
27
27
|
msgstr[0] ""
|
|
28
28
|
msgstr[1] ""
|
|
29
29
|
|
|
30
|
-
#: views/oauth-scope-error.hbs:5
|
|
31
|
-
msgid "Insufficient Permissions"
|
|
32
|
-
msgstr ""
|
|
33
|
-
|
|
34
|
-
#: views/oauth-scope-error.hbs:10
|
|
35
|
-
msgid ""
|
|
36
|
-
"All requested permissions are required for this service to function "
|
|
37
|
-
"properly. Some required permissions were not granted during sign-in."
|
|
38
|
-
msgstr ""
|
|
39
|
-
|
|
40
|
-
#: views/oauth-scope-error.hbs:14
|
|
41
|
-
msgid "The following permissions were not granted:"
|
|
42
|
-
msgstr ""
|
|
43
|
-
|
|
44
|
-
#: views/oauth-scope-error.hbs:23
|
|
45
|
-
msgid ""
|
|
46
|
-
"Please try again and make sure all permission checkboxes are selected on "
|
|
47
|
-
"the Google consent screen."
|
|
48
|
-
msgstr ""
|
|
49
|
-
|
|
50
|
-
#: views/oauth-scope-error.hbs:28
|
|
51
|
-
msgid "Try Again"
|
|
52
|
-
msgstr ""
|
|
53
|
-
|
|
54
30
|
#: views/redirect.hbs:1
|
|
55
31
|
msgid "Click <a href=\"%s\">here</a> to continue…"
|
|
56
32
|
msgstr ""
|
|
@@ -99,6 +75,30 @@ msgstr ""
|
|
|
99
75
|
msgid "Email address"
|
|
100
76
|
msgstr ""
|
|
101
77
|
|
|
78
|
+
#: views/oauth-scope-error.hbs:5
|
|
79
|
+
msgid "Insufficient Permissions"
|
|
80
|
+
msgstr ""
|
|
81
|
+
|
|
82
|
+
#: views/oauth-scope-error.hbs:10
|
|
83
|
+
msgid ""
|
|
84
|
+
"All requested permissions are required for this service to function "
|
|
85
|
+
"properly. Some required permissions were not granted during sign-in."
|
|
86
|
+
msgstr ""
|
|
87
|
+
|
|
88
|
+
#: views/oauth-scope-error.hbs:14
|
|
89
|
+
msgid "The following permissions were not granted:"
|
|
90
|
+
msgstr ""
|
|
91
|
+
|
|
92
|
+
#: views/oauth-scope-error.hbs:23
|
|
93
|
+
msgid ""
|
|
94
|
+
"Please try again and make sure all permission checkboxes are selected on "
|
|
95
|
+
"the Google consent screen."
|
|
96
|
+
msgstr ""
|
|
97
|
+
|
|
98
|
+
#: views/oauth-scope-error.hbs:28
|
|
99
|
+
msgid "Try Again"
|
|
100
|
+
msgstr ""
|
|
101
|
+
|
|
102
102
|
#: views/accounts/register/imap.hbs:13
|
|
103
103
|
msgid "Your name"
|
|
104
104
|
msgstr ""
|
|
@@ -254,19 +254,19 @@ msgid ""
|
|
|
254
254
|
"connect your account."
|
|
255
255
|
msgstr ""
|
|
256
256
|
|
|
257
|
-
#: lib/tools.js:
|
|
257
|
+
#: lib/tools.js:1056
|
|
258
258
|
#: lib/ui-routes/unsubscribe-routes.js:28
|
|
259
259
|
#: lib/ui-routes/unsubscribe-routes.js:92
|
|
260
260
|
msgid "Invalid input"
|
|
261
261
|
msgstr ""
|
|
262
262
|
|
|
263
|
-
#: lib/tools.js:
|
|
263
|
+
#: lib/tools.js:1893
|
|
264
264
|
msgid "Signature validation failed"
|
|
265
265
|
msgstr ""
|
|
266
266
|
|
|
267
|
-
#: lib/tools.js:
|
|
268
|
-
#: lib/tools.js:
|
|
269
|
-
#: lib/tools.js:
|
|
267
|
+
#: lib/tools.js:1916
|
|
268
|
+
#: lib/tools.js:1922
|
|
269
|
+
#: lib/tools.js:1927
|
|
270
270
|
#: lib/ui-routes/account-routes.js:976
|
|
271
271
|
msgid "Invalid or expired account setup URL"
|
|
272
272
|
msgstr ""
|
|
@@ -277,8 +277,8 @@ msgstr ""
|
|
|
277
277
|
#: lib/ui-routes/account-routes.js:748
|
|
278
278
|
#: lib/ui-routes/account-routes.js:1006
|
|
279
279
|
#: lib/ui-routes/account-routes.js:1098
|
|
280
|
-
#: workers/api.js:
|
|
281
|
-
#: workers/api.js:
|
|
280
|
+
#: workers/api.js:2292
|
|
281
|
+
#: workers/api.js:2646
|
|
282
282
|
msgid "Email Account Setup"
|
|
283
283
|
msgstr ""
|
|
284
284
|
|
|
@@ -399,7 +399,7 @@ msgstr ""
|
|
|
399
399
|
msgid "Couldn't process request. Try again."
|
|
400
400
|
msgstr ""
|
|
401
401
|
|
|
402
|
-
#: workers/api.js:
|
|
403
|
-
#: workers/api.js:
|
|
402
|
+
#: workers/api.js:3018
|
|
403
|
+
#: workers/api.js:3119
|
|
404
404
|
msgid "Requested page not found"
|
|
405
405
|
msgstr ""
|
|
@@ -76,6 +76,14 @@
|
|
|
76
76
|
{{errorMessage}}
|
|
77
77
|
{{/ui/tooltip-rich}}
|
|
78
78
|
{{/if}}
|
|
79
|
+
{{#if recentlyRestarted}}
|
|
80
|
+
{{#> ui/tooltip-rich icon="icon-[tabler--refresh] text-warning"}}
|
|
81
|
+
<strong>Recently restarted</strong><br>
|
|
82
|
+
This worker came online noticeably later than the main process, so it started
|
|
83
|
+
after the initial boot rather than with the rest of the fleet. See the Uptime
|
|
84
|
+
column for when it last started.
|
|
85
|
+
{{/ui/tooltip-rich}}
|
|
86
|
+
{{/if}}
|
|
79
87
|
</span>
|
|
80
88
|
</td>
|
|
81
89
|
<td><span class="text-base-content/60 font-mono text-sm">#{{formatInteger threadId userLocale}}</span></td>
|
package/workers/api.js
CHANGED
|
@@ -61,7 +61,7 @@ const HapiSwagger = require('hapi-swagger');
|
|
|
61
61
|
const pathlib = require('path');
|
|
62
62
|
|
|
63
63
|
const crypto = require('crypto');
|
|
64
|
-
const {
|
|
64
|
+
const { registeredPublishers, openChangeStream } = require('../lib/response-stream');
|
|
65
65
|
const { oauth2Apps, OAUTH_PROVIDERS } = require('../lib/oauth2-apps');
|
|
66
66
|
|
|
67
67
|
const handlebars = require('handlebars');
|
|
@@ -101,27 +101,10 @@ const {
|
|
|
101
101
|
NONCE_BYTES
|
|
102
102
|
} = consts;
|
|
103
103
|
|
|
104
|
-
const
|
|
105
|
-
const chatRoutes = require('../lib/api-routes/chat-routes');
|
|
104
|
+
const registerApiRoutes = require('../lib/api-routes');
|
|
106
105
|
const bullBoardRoutes = require('../lib/api-routes/bull-board-routes');
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
const exportRoutes = require('../lib/api-routes/export-routes');
|
|
110
|
-
const pubsubRoutes = require('../lib/api-routes/pubsub-routes');
|
|
111
|
-
const tokenRoutes = require('../lib/api-routes/token-routes');
|
|
112
|
-
const mailboxRoutes = require('../lib/api-routes/mailbox-routes');
|
|
113
|
-
const settingsRoutes = require('../lib/api-routes/settings-routes');
|
|
114
|
-
const statsRoutes = require('../lib/api-routes/stats-routes');
|
|
115
|
-
const licenseRoutes = require('../lib/api-routes/license-routes');
|
|
116
|
-
const outboxRoutes = require('../lib/api-routes/outbox-routes');
|
|
117
|
-
const webhookRouteRoutes = require('../lib/api-routes/webhook-route-routes');
|
|
118
|
-
const oauth2AppRoutes = require('../lib/api-routes/oauth2-app-routes');
|
|
119
|
-
const gatewayRoutes = require('../lib/api-routes/gateway-routes');
|
|
120
|
-
const deliveryTestRoutes = require('../lib/api-routes/delivery-test-routes');
|
|
121
|
-
const blocklistRoutes = require('../lib/api-routes/blocklist-routes');
|
|
122
|
-
const submitRoutes = require('../lib/api-routes/submit-routes');
|
|
123
|
-
|
|
124
|
-
const { imapSchema, smtpSchema, oauth2Schema, accountIdSchema, headerTimeoutSchema, errorResponses } = require('../lib/schemas');
|
|
106
|
+
|
|
107
|
+
const { imapSchema, smtpSchema, oauth2Schema, accountIdSchema, headerTimeoutSchema } = require('../lib/schemas');
|
|
125
108
|
|
|
126
109
|
const OAuth2ProviderSchema = Joi.string()
|
|
127
110
|
.valid(...Object.keys(OAUTH_PROVIDERS))
|
|
@@ -279,73 +262,6 @@ logger.info({
|
|
|
279
262
|
|
|
280
263
|
const TRACKER_IMAGE = Buffer.from('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', 'base64');
|
|
281
264
|
|
|
282
|
-
let registeredPublishers = new Set();
|
|
283
|
-
|
|
284
|
-
class ResponseStream extends Transform {
|
|
285
|
-
constructor() {
|
|
286
|
-
super();
|
|
287
|
-
registeredPublishers.add(this);
|
|
288
|
-
this.periodicKeepAliveTimer = false;
|
|
289
|
-
this.updateTimer();
|
|
290
|
-
|
|
291
|
-
this._finalized = false;
|
|
292
|
-
|
|
293
|
-
// Ensure cleanup on all stream end scenarios
|
|
294
|
-
this.on('error', () => this.finalize());
|
|
295
|
-
this.once('close', () => this.finalize());
|
|
296
|
-
this.once('end', () => this.finalize());
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
updateTimer() {
|
|
300
|
-
clearTimeout(this.periodicKeepAliveTimer);
|
|
301
|
-
this.periodicKeepAliveTimer = setTimeout(() => {
|
|
302
|
-
if (this._finalized || this.destroyed) return;
|
|
303
|
-
this.write(': still here\n\n');
|
|
304
|
-
if (this._compressor) {
|
|
305
|
-
this._compressor.flush();
|
|
306
|
-
}
|
|
307
|
-
this.updateTimer();
|
|
308
|
-
}, 90 * 1000);
|
|
309
|
-
this.periodicKeepAliveTimer.unref();
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
setCompressor(compressor) {
|
|
313
|
-
this._compressor = compressor;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
sendMessage(payload) {
|
|
317
|
-
if (this._finalized || this.destroyed) return;
|
|
318
|
-
let sendData = JSON.stringify(payload);
|
|
319
|
-
this.write('event: message\ndata:' + sendData + '\n\n');
|
|
320
|
-
if (this._compressor) {
|
|
321
|
-
this._compressor.flush();
|
|
322
|
-
}
|
|
323
|
-
this.updateTimer();
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
finalize() {
|
|
327
|
-
if (this._finalized) return; // Prevent double cleanup
|
|
328
|
-
this._finalized = true;
|
|
329
|
-
|
|
330
|
-
clearTimeout(this.periodicKeepAliveTimer);
|
|
331
|
-
registeredPublishers.delete(this);
|
|
332
|
-
|
|
333
|
-
if (!this.destroyed) {
|
|
334
|
-
this.destroy();
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
_transform(data, encoding, done) {
|
|
339
|
-
this.push(data);
|
|
340
|
-
done();
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
_flush(done) {
|
|
344
|
-
this.finalize();
|
|
345
|
-
done();
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
265
|
let callQueue = new Map();
|
|
350
266
|
let mids = 0;
|
|
351
267
|
|
|
@@ -2779,124 +2695,26 @@ Include your token in requests using one of these methods:
|
|
|
2779
2695
|
}
|
|
2780
2696
|
});
|
|
2781
2697
|
|
|
2782
|
-
// setup
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
// setup "chat with email" routes (deprecated Document Store feature; only when enabled)
|
|
2786
|
-
if (documentStoreFeatureEnabled) {
|
|
2787
|
-
await chatRoutes({ server, call, CORS_CONFIG });
|
|
2788
|
-
}
|
|
2789
|
-
|
|
2790
|
-
// setup account CRUD routes
|
|
2791
|
-
await accountRoutes({
|
|
2698
|
+
// setup every /v1 route module (wiring lives in lib/api-routes/index.js so the route table
|
|
2699
|
+
// can be captured without booting this worker - see test/api-routes-table-test.js)
|
|
2700
|
+
await registerApiRoutes({
|
|
2792
2701
|
server,
|
|
2793
2702
|
call,
|
|
2703
|
+
notify,
|
|
2794
2704
|
documentsQueue,
|
|
2795
|
-
|
|
2796
|
-
imapSchema,
|
|
2797
|
-
smtpSchema,
|
|
2798
|
-
CORS_CONFIG,
|
|
2799
|
-
AccountTypeSchema,
|
|
2800
|
-
OAuth2ProviderSchema,
|
|
2801
|
-
metrics
|
|
2802
|
-
});
|
|
2803
|
-
|
|
2804
|
-
// setup message routes
|
|
2805
|
-
await messageRoutes({
|
|
2806
|
-
server,
|
|
2807
|
-
call,
|
|
2705
|
+
metrics,
|
|
2808
2706
|
CORS_CONFIG,
|
|
2707
|
+
FLAG_SORT_ORDER,
|
|
2708
|
+
SMTP_TEST_HOST,
|
|
2809
2709
|
MAX_ATTACHMENT_SIZE,
|
|
2810
2710
|
MAX_BODY_SIZE,
|
|
2811
2711
|
MAX_PAYLOAD_TIMEOUT,
|
|
2812
|
-
documentStoreFeatureEnabled
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
CORS_CONFIG
|
|
2819
|
-
});
|
|
2820
|
-
|
|
2821
|
-
// setup Pub/Sub status route
|
|
2822
|
-
await pubsubRoutes({ server, CORS_CONFIG });
|
|
2823
|
-
|
|
2824
|
-
// setup access token routes
|
|
2825
|
-
await tokenRoutes({ server, call, CORS_CONFIG });
|
|
2826
|
-
|
|
2827
|
-
// setup mailbox routes
|
|
2828
|
-
await mailboxRoutes({ server, call, CORS_CONFIG, FLAG_SORT_ORDER });
|
|
2829
|
-
|
|
2830
|
-
// setup settings routes
|
|
2831
|
-
await settingsRoutes({ server, notify, CORS_CONFIG });
|
|
2832
|
-
|
|
2833
|
-
// setup stats route
|
|
2834
|
-
await statsRoutes({ server, call, CORS_CONFIG });
|
|
2835
|
-
|
|
2836
|
-
// setup license routes
|
|
2837
|
-
await licenseRoutes({ server, call, CORS_CONFIG });
|
|
2838
|
-
|
|
2839
|
-
// setup outbox routes
|
|
2840
|
-
await outboxRoutes({ server, CORS_CONFIG });
|
|
2841
|
-
|
|
2842
|
-
// setup webhook route management routes
|
|
2843
|
-
await webhookRouteRoutes({ server, CORS_CONFIG });
|
|
2844
|
-
|
|
2845
|
-
// setup OAuth2 application routes
|
|
2846
|
-
await oauth2AppRoutes({ server, call, CORS_CONFIG, OAuth2ProviderSchema });
|
|
2847
|
-
|
|
2848
|
-
// setup SMTP gateway routes
|
|
2849
|
-
await gatewayRoutes({ server, call, CORS_CONFIG });
|
|
2850
|
-
|
|
2851
|
-
// setup delivery test routes
|
|
2852
|
-
await deliveryTestRoutes({ server, call, CORS_CONFIG, SMTP_TEST_HOST });
|
|
2853
|
-
|
|
2854
|
-
// setup blocklist routes
|
|
2855
|
-
await blocklistRoutes({ server, call, CORS_CONFIG });
|
|
2856
|
-
|
|
2857
|
-
// setup message submit route
|
|
2858
|
-
await submitRoutes({ server, call, CORS_CONFIG, MAX_ATTACHMENT_SIZE, MAX_BODY_SIZE, MAX_PAYLOAD_TIMEOUT });
|
|
2859
|
-
|
|
2860
|
-
server.route({
|
|
2861
|
-
method: 'GET',
|
|
2862
|
-
path: '/v1/changes',
|
|
2863
|
-
|
|
2864
|
-
async handler(request, h) {
|
|
2865
|
-
request.app.stream = new ResponseStream();
|
|
2866
|
-
finished(request.app.stream, err => request.app.stream.finalize(err));
|
|
2867
|
-
setImmediate(() => {
|
|
2868
|
-
try {
|
|
2869
|
-
request.app.stream.write(`: EmailEngine v${packageData.version}\n\n`);
|
|
2870
|
-
} catch (err) {
|
|
2871
|
-
// ignore
|
|
2872
|
-
}
|
|
2873
|
-
});
|
|
2874
|
-
return h
|
|
2875
|
-
.response(request.app.stream)
|
|
2876
|
-
.header('X-Accel-Buffering', 'no')
|
|
2877
|
-
.header('Connection', 'keep-alive')
|
|
2878
|
-
.header('Cache-Control', 'no-cache')
|
|
2879
|
-
.type('text/event-stream');
|
|
2880
|
-
},
|
|
2881
|
-
|
|
2882
|
-
options: {
|
|
2883
|
-
description: 'Stream state changes',
|
|
2884
|
-
notes: 'Stream account state changes as an EventSource',
|
|
2885
|
-
tags: ['api', 'Account'],
|
|
2886
|
-
|
|
2887
|
-
plugins: {
|
|
2888
|
-
'hapi-swagger': {
|
|
2889
|
-
produces: ['text/event-stream'],
|
|
2890
|
-
responses: errorResponses(401, 403, 429, 500)
|
|
2891
|
-
}
|
|
2892
|
-
},
|
|
2893
|
-
|
|
2894
|
-
auth: {
|
|
2895
|
-
strategy: 'api-token',
|
|
2896
|
-
mode: 'required'
|
|
2897
|
-
},
|
|
2898
|
-
cors: CORS_CONFIG
|
|
2899
|
-
}
|
|
2712
|
+
documentStoreFeatureEnabled,
|
|
2713
|
+
oauth2Schema,
|
|
2714
|
+
imapSchema,
|
|
2715
|
+
smtpSchema,
|
|
2716
|
+
AccountTypeSchema,
|
|
2717
|
+
OAuth2ProviderSchema
|
|
2900
2718
|
});
|
|
2901
2719
|
|
|
2902
2720
|
// Web UI routes
|
|
@@ -3266,23 +3084,9 @@ Include your token in requests using one of these methods:
|
|
|
3266
3084
|
method: 'GET',
|
|
3267
3085
|
path: '/admin/changes',
|
|
3268
3086
|
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
setImmediate(() => {
|
|
3273
|
-
try {
|
|
3274
|
-
request.app.stream.write(`: EmailEngine v${packageData.version}\n\n`);
|
|
3275
|
-
} catch (err) {
|
|
3276
|
-
// ignore
|
|
3277
|
-
}
|
|
3278
|
-
});
|
|
3279
|
-
return h
|
|
3280
|
-
.response(request.app.stream)
|
|
3281
|
-
.header('X-Accel-Buffering', 'no')
|
|
3282
|
-
.header('Connection', 'keep-alive')
|
|
3283
|
-
.header('Cache-Control', 'no-cache')
|
|
3284
|
-
.type('text/event-stream');
|
|
3285
|
-
}
|
|
3087
|
+
// Same feed as /v1/changes (lib/api-routes/changes-routes.js), opened through the shared
|
|
3088
|
+
// helper so the two can not drift apart on framing or on stream cleanup.
|
|
3089
|
+
handler: openChangeStream
|
|
3286
3090
|
});
|
|
3287
3091
|
|
|
3288
3092
|
// setup web UI
|
package/workers/export.js
CHANGED
|
@@ -20,7 +20,18 @@ const {
|
|
|
20
20
|
const { getDuration, readEnvValue, threadStats, maybeReloadHttpProxyAgent } = require('../lib/tools');
|
|
21
21
|
const { webhooks: Webhooks } = require('../lib/webhooks');
|
|
22
22
|
const settings = require('../lib/settings');
|
|
23
|
-
const {
|
|
23
|
+
const {
|
|
24
|
+
Export,
|
|
25
|
+
isTransientError,
|
|
26
|
+
isSkippableError,
|
|
27
|
+
isFolderMissingError,
|
|
28
|
+
isRetryableError,
|
|
29
|
+
resolveExportLimit,
|
|
30
|
+
isExportLimitReached,
|
|
31
|
+
parseActiveEntry,
|
|
32
|
+
getExportKey,
|
|
33
|
+
ACTIVE_EXPORTS_KEY
|
|
34
|
+
} = require('../lib/export');
|
|
24
35
|
|
|
25
36
|
const { initSentry } = require('../lib/sentry');
|
|
26
37
|
initSentry('export');
|
|
@@ -174,7 +185,7 @@ async function indexMessages(job, exportData) {
|
|
|
174
185
|
|
|
175
186
|
await Export.update(account, exportId, { foldersTotal: foldersToProcess.length });
|
|
176
187
|
|
|
177
|
-
const maxMessages =
|
|
188
|
+
const maxMessages = resolveExportLimit(await settings.get('exportMaxMessages'), DEFAULT_EXPORT_MAX_MESSAGES);
|
|
178
189
|
|
|
179
190
|
logger.info({ msg: 'Starting export indexing', account, exportId, foldersToProcess: foldersToProcess.length, maxMessages: maxMessages || 'unlimited' });
|
|
180
191
|
|
|
@@ -249,7 +260,7 @@ async function indexMessages(job, exportData) {
|
|
|
249
260
|
// The folder indexed successfully (failures throw above); count it toward progress.
|
|
250
261
|
await Export.update(account, exportId, { foldersScanned: i + 1 });
|
|
251
262
|
|
|
252
|
-
if (
|
|
263
|
+
if (isExportLimitReached(totalIndexed, maxMessages)) {
|
|
253
264
|
truncated = true;
|
|
254
265
|
logger.warn({
|
|
255
266
|
msg: 'Export indexing truncated: message limit reached',
|
|
@@ -354,8 +365,8 @@ async function exportMessages(job, exportData) {
|
|
|
354
365
|
const rawMaxBytes = Number(exportData.maxBytes);
|
|
355
366
|
// Preserve an explicit 0 ("unlimited" per the API contract); only fall back when unset/invalid.
|
|
356
367
|
const maxBytes = Number.isFinite(rawMaxBytes) ? rawMaxBytes : 5 * 1024 * 1024;
|
|
357
|
-
const maxMessageSize = (await settings.get('exportMaxMessageSize')
|
|
358
|
-
const maxExportSize =
|
|
368
|
+
const maxMessageSize = resolveExportLimit(await settings.get('exportMaxMessageSize'), DEFAULT_EXPORT_MAX_MESSAGE_SIZE);
|
|
369
|
+
const maxExportSize = resolveExportLimit(await settings.get('exportMaxSize'), DEFAULT_EXPORT_MAX_SIZE);
|
|
359
370
|
const isEncrypted = exportData.isEncrypted === '1';
|
|
360
371
|
|
|
361
372
|
const accountObject = new Account({
|
|
@@ -576,7 +587,7 @@ async function exportMessages(job, exportData) {
|
|
|
576
587
|
}
|
|
577
588
|
} else if (result && result.data) {
|
|
578
589
|
await processMessage(result.data, entry);
|
|
579
|
-
if (
|
|
590
|
+
if (isExportLimitReached(totalBytesWritten, maxExportSize)) {
|
|
580
591
|
sizeLimitReached = true;
|
|
581
592
|
break;
|
|
582
593
|
}
|
|
@@ -661,7 +672,7 @@ async function exportMessages(job, exportData) {
|
|
|
661
672
|
|
|
662
673
|
if (message) {
|
|
663
674
|
await processMessage(message, entry);
|
|
664
|
-
if (
|
|
675
|
+
if (isExportLimitReached(totalBytesWritten, maxExportSize)) {
|
|
665
676
|
sizeLimitReached = true;
|
|
666
677
|
break;
|
|
667
678
|
}
|
|
@@ -883,16 +894,19 @@ function onCommand(command) {
|
|
|
883
894
|
setInterval(
|
|
884
895
|
async () => {
|
|
885
896
|
try {
|
|
886
|
-
|
|
897
|
+
// The set key, the entry encoding and the export key all come from lib/export.js.
|
|
898
|
+
// Hand-building them here meant this cleanup and the limiter that writes the
|
|
899
|
+
// entries could drift apart: entries added under one encoding and removed under
|
|
900
|
+
// another leave the active set growing forever, and once it reaches the global
|
|
901
|
+
// limit every export in the deployment is refused with 429.
|
|
902
|
+
const activeExports = await redis.smembers(ACTIVE_EXPORTS_KEY);
|
|
887
903
|
for (const entry of activeExports) {
|
|
888
|
-
const
|
|
889
|
-
if (
|
|
890
|
-
const
|
|
891
|
-
const entryExportId = entry.substring(separatorIndex + 1);
|
|
892
|
-
const exists = await redis.exists(`${REDIS_PREFIX}exp:${entryAccount}:${entryExportId}`);
|
|
904
|
+
const parsed = parseActiveEntry(entry);
|
|
905
|
+
if (!parsed) continue;
|
|
906
|
+
const exists = await redis.exists(getExportKey(parsed.account, parsed.exportId));
|
|
893
907
|
if (!exists) {
|
|
894
|
-
await redis.srem(
|
|
895
|
-
logger.info({ msg: 'Cleaned stale active set entry', account:
|
|
908
|
+
await redis.srem(ACTIVE_EXPORTS_KEY, entry);
|
|
909
|
+
logger.info({ msg: 'Cleaned stale active set entry', account: parsed.account, exportId: parsed.exportId });
|
|
896
910
|
}
|
|
897
911
|
}
|
|
898
912
|
} catch (err) {
|