emailengine-app 2.84.2 → 2.86.0
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/.ncurc.js +29 -9
- package/.prettierignore +5 -1
- package/.prettierrc.js +2 -0
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +107 -0
- package/Dockerfile +20 -1
- package/ENVIRONMENT.md +139 -0
- package/README.md +2 -2
- package/bin/emailengine.js +434 -408
- package/config/default.toml +2 -0
- package/copy-static-files.sh +41 -14
- package/data/google-crawlers.json +1 -1
- package/data/public_suffix_list.dat +16563 -0
- package/eslint.config.js +81 -99
- package/lib/account-assignment.js +19 -0
- package/lib/account.js +230 -170
- package/lib/api-error-codes.js +49 -0
- package/lib/api-reference/format.js +4 -3
- package/lib/api-reference/model.js +6 -1
- package/lib/api-routes/account-routes.js +255 -38
- package/lib/api-routes/blocklist-routes.js +91 -4
- package/lib/api-routes/delivery-test-routes.js +27 -4
- package/lib/api-routes/export-routes.js +28 -2
- package/lib/api-routes/gateway-routes.js +110 -12
- package/lib/api-routes/index.js +4 -0
- package/lib/api-routes/license-routes.js +2 -2
- package/lib/api-routes/mailbox-routes.js +44 -5
- package/lib/api-routes/message-routes.js +112 -10
- package/lib/api-routes/oauth2-app-routes.js +63 -23
- package/lib/api-routes/outbox-routes.js +97 -52
- package/lib/api-routes/permission-map.js +67 -7
- package/lib/api-routes/scoped-routes.js +74 -0
- package/lib/api-routes/settings-routes.js +34 -6
- package/lib/api-routes/stats-routes.js +5 -1
- package/lib/api-routes/submit-routes.js +337 -309
- package/lib/api-routes/template-routes.js +45 -8
- package/lib/api-routes/token-routes.js +152 -100
- package/lib/api-routes/webhook-delivery-routes.js +262 -0
- package/lib/api-routes/webhook-route-routes.js +132 -6
- package/lib/bounce-detect.js +397 -205
- package/lib/calendar-event.js +81 -1
- package/lib/consts.js +38 -45
- package/lib/db.js +14 -6
- package/lib/delivery-error.js +6 -0
- package/lib/deprecations.js +270 -0
- package/lib/email-client/base-client.js +137 -184
- package/lib/email-client/fallback-poll.js +62 -0
- package/lib/email-client/gmail-client.js +60 -22
- package/lib/email-client/imap/adaptive-idle-store.js +73 -0
- package/lib/email-client/imap/adaptive-idle.js +278 -0
- package/lib/email-client/imap/connection-errors.js +14 -1
- package/lib/email-client/imap/idle-settings.js +31 -5
- package/lib/email-client/imap/listing-diff.js +37 -0
- package/lib/email-client/imap/mailbox.js +372 -242
- package/lib/email-client/imap/subconnection.js +8 -30
- package/lib/email-client/imap/sync-operations.js +220 -127
- package/lib/email-client/imap-client.js +228 -164
- package/lib/email-client/message-builder.js +14 -79
- package/lib/email-client/notification-handler.js +1 -2
- package/lib/email-client/outlook-client.js +372 -338
- package/lib/email-client/smtp-pool-manager.js +16 -13
- package/lib/email-client/sync-state-fields.js +19 -0
- package/lib/encrypt.js +157 -41
- package/lib/enum-descriptions.js +3 -1
- package/lib/env-setting-overrides.js +288 -0
- package/lib/export-worker.js +751 -0
- package/lib/export.js +64 -15
- package/lib/gateway.js +19 -4
- package/lib/get-raw-email.js +25 -107
- package/lib/hapi-request-logger.js +107 -0
- package/lib/health.js +75 -0
- package/lib/imapproxy/imap-core/README.md +6 -5
- package/lib/lock-run.js +119 -0
- package/lib/logger-consts.js +48 -0
- package/lib/logger.js +1 -1
- package/lib/lua/z-head-scores.lua +28 -0
- package/lib/mcp/tools.js +37 -8
- package/lib/network-errors.js +1 -1
- package/lib/node-version.js +24 -0
- package/lib/notify-attachments.js +36 -0
- package/lib/oauth/outlook-mailbox.js +35 -0
- package/lib/oauth/state.js +24 -0
- package/lib/oauth2-apps.js +631 -656
- package/lib/outbox.js +184 -54
- package/lib/parse-message.js +3 -3
- package/lib/pbkdf2-phc.js +1 -1
- package/lib/privileged-settings.js +2 -2
- package/lib/queue-browser/definitions.js +11 -0
- package/lib/queue-browser/index.js +68 -19
- package/lib/queue-job-actions.js +18 -1
- package/lib/queue-retention.js +48 -12
- package/lib/queue-stats.js +11 -2
- package/lib/read-env-value.js +3 -0
- package/lib/redis-memory-warnings.js +99 -0
- package/lib/redis-reconnect.js +29 -0
- package/lib/request-timing.js +23 -0
- package/lib/respawn-backoff.js +35 -0
- package/lib/rewrite-text-nodes.js +19 -59
- package/lib/schemas.js +164 -40
- package/lib/settings.js +6 -2
- package/lib/smtp-auth.js +19 -1
- package/lib/sso.js +1 -1
- package/lib/swagger-options.js +1 -1
- package/lib/thread-diagnostics.js +63 -0
- package/lib/timezones.js +109 -0
- package/lib/tls/provision.js +6 -3
- package/lib/token-audit-log.js +19 -20
- package/lib/token-permission-view.js +7 -6
- package/lib/tools.js +48 -51
- package/lib/totp.js +2 -5
- package/lib/translations.js +1 -2
- package/lib/ui-routes/account-routes.js +475 -454
- package/lib/ui-routes/account-setup.js +99 -0
- package/lib/ui-routes/admin-config-routes.js +152 -100
- package/lib/ui-routes/admin-entities-routes.js +93 -21
- package/lib/ui-routes/auth-routes.js +90 -38
- package/lib/ui-routes/imap-idle-field.js +1 -1
- package/lib/ui-routes/internals-routes.js +5 -0
- package/lib/ui-routes/oauth-config-routes.js +124 -82
- package/lib/ui-routes/outlook-subscription-view.js +1 -1
- package/lib/ui-routes/overridable-fields.js +84 -0
- package/lib/ui-routes/queue-routes.js +8 -5
- package/lib/ui-routes/route-helpers.js +19 -3
- package/lib/ui-routes/settings-page.js +6 -0
- package/lib/ui-routes/tls-config-routes.js +58 -15
- package/lib/utils/back-off.js +82 -0
- package/lib/utils/decode-headers.js +3 -12
- package/lib/utils/filter-empty.js +20 -0
- package/lib/utils/int-setting.js +48 -0
- package/lib/utils/murmurhash3.js +66 -0
- package/lib/utils/public-suffix.js +122 -0
- package/lib/utils/random-id.js +26 -0
- package/lib/utils/tracking-settings.js +35 -0
- package/lib/utils/version.js +74 -0
- package/lib/web-safe-html.js +18 -105
- package/lib/webhook-delivery.js +461 -0
- package/lib/webhook-failures.js +132 -0
- package/lib/webhook-request.js +29 -1
- package/lib/webhook-routing.js +56 -0
- package/lib/webhook-test.js +88 -0
- package/lib/webhooks.js +93 -45
- package/lib/worker-rpc-error.js +2 -1
- package/package.json +37 -38
- package/sbom.json +7902 -1
- package/server.js +784 -518
- package/static/js/ace/ace.js +1 -1
- package/static/licenses.html +225 -1060
- package/translations/messages.pot +62 -63
- package/views/config/ai.hbs +1 -1
- package/views/config/security.hbs +24 -2
- package/views/config/service.hbs +47 -0
- package/views/config/webhooks.hbs +36 -0
- package/views/internals/index.hbs +8 -0
- package/views/partials/queue_retention_note.hbs +12 -8
- package/views/partials/ui/env-managed-alert.hbs +16 -7
- package/views/partials/webhook_form.hbs +1 -1
- package/views/suppression-lists/index.hbs +1 -1
- package/workers/api.js +840 -611
- package/workers/export.js +17 -632
- package/workers/imap.js +13 -0
- package/workers/smtp.js +9 -11
- package/workers/submit.js +1 -1
- package/workers/webhooks.js +18 -448
- package/lib/email-client/outlook-fallback-poll.js +0 -30
|
@@ -9,8 +9,8 @@ const { handleError } = require('./route-helpers');
|
|
|
9
9
|
const BEHAVIOR = require('./behavior-notes');
|
|
10
10
|
const { IMPACT } = require('./operation-impact');
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
const {
|
|
12
|
+
function registerCreateExport(server, args) {
|
|
13
|
+
const { CORS_CONFIG } = args;
|
|
14
14
|
|
|
15
15
|
server.route({
|
|
16
16
|
method: 'POST',
|
|
@@ -74,6 +74,10 @@ async function init(args) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function registerGetExport(server, args) {
|
|
80
|
+
const { CORS_CONFIG } = args;
|
|
77
81
|
|
|
78
82
|
server.route({
|
|
79
83
|
method: 'GET',
|
|
@@ -128,6 +132,10 @@ async function init(args) {
|
|
|
128
132
|
}
|
|
129
133
|
}
|
|
130
134
|
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function registerDownloadExport(server, args) {
|
|
138
|
+
const { CORS_CONFIG } = args;
|
|
131
139
|
|
|
132
140
|
server.route({
|
|
133
141
|
method: 'GET',
|
|
@@ -188,6 +196,10 @@ async function init(args) {
|
|
|
188
196
|
}
|
|
189
197
|
}
|
|
190
198
|
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function registerDeleteExport(server, args) {
|
|
202
|
+
const { CORS_CONFIG } = args;
|
|
191
203
|
|
|
192
204
|
server.route({
|
|
193
205
|
method: 'DELETE',
|
|
@@ -245,6 +257,10 @@ async function init(args) {
|
|
|
245
257
|
}
|
|
246
258
|
}
|
|
247
259
|
});
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function registerListExports(server, args) {
|
|
263
|
+
const { CORS_CONFIG } = args;
|
|
248
264
|
|
|
249
265
|
server.route({
|
|
250
266
|
method: 'GET',
|
|
@@ -311,4 +327,14 @@ async function init(args) {
|
|
|
311
327
|
});
|
|
312
328
|
}
|
|
313
329
|
|
|
330
|
+
async function init(args) {
|
|
331
|
+
const { server } = args;
|
|
332
|
+
|
|
333
|
+
registerCreateExport(server, args);
|
|
334
|
+
registerGetExport(server, args);
|
|
335
|
+
registerDownloadExport(server, args);
|
|
336
|
+
registerDeleteExport(server, args);
|
|
337
|
+
registerListExports(server, args);
|
|
338
|
+
}
|
|
339
|
+
|
|
314
340
|
module.exports = init;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const Joi = require('joi');
|
|
4
4
|
const { redis } = require('../db');
|
|
5
|
-
const { Gateway } = require('../gateway');
|
|
5
|
+
const { Gateway, gatewaySmtpConfig } = require('../gateway');
|
|
6
6
|
const getSecret = require('../get-secret');
|
|
7
|
-
const { failAction } = require('../tools');
|
|
7
|
+
const { failAction, verifyAccountInfo } = require('../tools');
|
|
8
8
|
const { handleError, maskSecrets, MASKED, MASK_NOTE } = require('./route-helpers');
|
|
9
|
-
const { apiResponses, apiBoolean, formBoolean, requireTlsSchema } = require('../schemas');
|
|
9
|
+
const { apiResponses, apiBoolean, formBoolean, requireTlsSchema, verifyResultSchema, listQuerySchema } = require('../schemas');
|
|
10
10
|
const { ENUM_DESCRIPTIONS } = require('../enum-descriptions');
|
|
11
11
|
const { IMPACT } = require('./operation-impact');
|
|
12
12
|
const { MCP_MAX_PAGE_SIZE } = require('../consts');
|
|
@@ -18,7 +18,7 @@ const gatewayRequireTlsSchema = requireTlsSchema('GatewayRequireTLS', formBoolea
|
|
|
18
18
|
|
|
19
19
|
const gatewayLastErrorSchema = Joi.object({
|
|
20
20
|
created: Joi.number().integer().example(1623868624153).description('Timestamp of the error as milliseconds from epoch'),
|
|
21
|
-
status: Joi.string().valid('error').example('error').description('Status of the last delivery attempt'),
|
|
21
|
+
status: Joi.string().valid('error').example('error').description('Status of the last delivery attempt').label('GatewayErrorStatus'),
|
|
22
22
|
response: Joi.string().example('535 Authentication failed').description('SMTP server response for the failed delivery'),
|
|
23
23
|
responseCode: Joi.number().integer().example(535).description('SMTP response code'),
|
|
24
24
|
code: Joi.string().example('EAUTH').description('Error type identifier'),
|
|
@@ -35,8 +35,8 @@ const gatewayLastErrorSchema = Joi.object({
|
|
|
35
35
|
.description('Information about the last failed delivery attempt using this gateway')
|
|
36
36
|
.label('GatewayErrorEntry');
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
const {
|
|
38
|
+
function registerListGateways(server, args) {
|
|
39
|
+
const { call, CORS_CONFIG } = args;
|
|
40
40
|
|
|
41
41
|
server.route({
|
|
42
42
|
method: 'GET',
|
|
@@ -46,7 +46,7 @@ async function init(args) {
|
|
|
46
46
|
try {
|
|
47
47
|
let gatewayObject = new Gateway({ redis, gateway: request.params.gateway, call, secret: await getSecret() });
|
|
48
48
|
|
|
49
|
-
const listing = await gatewayObject.listGateways(request.query.page, request.query.pageSize);
|
|
49
|
+
const listing = await gatewayObject.listGateways(request.query.page, request.query.pageSize, request.query.query);
|
|
50
50
|
|
|
51
51
|
for (const entry of listing.gateways || []) {
|
|
52
52
|
maskSecrets(entry);
|
|
@@ -60,7 +60,7 @@ async function init(args) {
|
|
|
60
60
|
|
|
61
61
|
options: {
|
|
62
62
|
description: 'List gateways',
|
|
63
|
-
notes: 'Lists
|
|
63
|
+
notes: 'Lists the stored SMTP gateways, one page at a time, with their delivery counters and last error. Passwords are not included.',
|
|
64
64
|
tags: ['api', 'SMTP Gateway'],
|
|
65
65
|
|
|
66
66
|
plugins: {
|
|
@@ -99,7 +99,8 @@ async function init(args) {
|
|
|
99
99
|
.example(0)
|
|
100
100
|
.description('Page number (zero indexed, so use 0 for first page)')
|
|
101
101
|
.label('PageNumber'),
|
|
102
|
-
pageSize: Joi.number().integer().min(1).max(1000).default(20).example(20).description('How many entries per page').label('PageSize')
|
|
102
|
+
pageSize: Joi.number().integer().min(1).max(1000).default(20).example(20).description('How many entries per page').label('PageSize'),
|
|
103
|
+
query: listQuerySchema('gateway ID, name, host or username', 'GatewaysListQuery')
|
|
103
104
|
}).label('GatewaysFilter')
|
|
104
105
|
},
|
|
105
106
|
|
|
@@ -129,6 +130,10 @@ async function init(args) {
|
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function registerGetGateway(server, args) {
|
|
136
|
+
const { call, CORS_CONFIG } = args;
|
|
132
137
|
|
|
133
138
|
server.route({
|
|
134
139
|
method: 'GET',
|
|
@@ -246,6 +251,10 @@ async function init(args) {
|
|
|
246
251
|
}
|
|
247
252
|
}
|
|
248
253
|
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function registerCreateGateway(server, args) {
|
|
257
|
+
const { call, CORS_CONFIG } = args;
|
|
249
258
|
|
|
250
259
|
server.route({
|
|
251
260
|
method: 'POST',
|
|
@@ -264,7 +273,7 @@ async function init(args) {
|
|
|
264
273
|
|
|
265
274
|
options: {
|
|
266
275
|
description: 'Register new gateway',
|
|
267
|
-
notes: '
|
|
276
|
+
notes: "Stores an SMTP relay that messages can be sent through instead of the account's own SMTP server, by naming it as `gateway` when submitting.",
|
|
268
277
|
tags: ['api', 'SMTP Gateway'],
|
|
269
278
|
|
|
270
279
|
plugins: {
|
|
@@ -350,6 +359,10 @@ async function init(args) {
|
|
|
350
359
|
}
|
|
351
360
|
}
|
|
352
361
|
});
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function registerUpdateGateway(server, args) {
|
|
365
|
+
const { call, CORS_CONFIG } = args;
|
|
353
366
|
|
|
354
367
|
server.route({
|
|
355
368
|
method: 'PUT',
|
|
@@ -366,7 +379,7 @@ async function init(args) {
|
|
|
366
379
|
},
|
|
367
380
|
options: {
|
|
368
381
|
description: 'Update gateway info',
|
|
369
|
-
notes: '
|
|
382
|
+
notes: 'Changes the stored settings of an SMTP gateway. Fields left out of the request keep their stored values, the password included.',
|
|
370
383
|
tags: ['api', 'SMTP Gateway'],
|
|
371
384
|
|
|
372
385
|
plugins: {
|
|
@@ -435,6 +448,10 @@ async function init(args) {
|
|
|
435
448
|
}
|
|
436
449
|
}
|
|
437
450
|
});
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function registerDeleteGateway(server, args) {
|
|
454
|
+
const { CORS_CONFIG } = args;
|
|
438
455
|
|
|
439
456
|
server.route({
|
|
440
457
|
method: 'DELETE',
|
|
@@ -455,7 +472,7 @@ async function init(args) {
|
|
|
455
472
|
},
|
|
456
473
|
options: {
|
|
457
474
|
description: 'Remove SMTP gateway',
|
|
458
|
-
notes: '
|
|
475
|
+
notes: 'Deletes a stored SMTP gateway. Messages queued for it fail to deliver.',
|
|
459
476
|
tags: ['api', 'SMTP Gateway'],
|
|
460
477
|
|
|
461
478
|
plugins: {
|
|
@@ -500,4 +517,85 @@ async function init(args) {
|
|
|
500
517
|
});
|
|
501
518
|
}
|
|
502
519
|
|
|
520
|
+
function registerVerifyGateway(server, args) {
|
|
521
|
+
const { CORS_CONFIG } = args;
|
|
522
|
+
|
|
523
|
+
server.route({
|
|
524
|
+
method: 'POST',
|
|
525
|
+
path: '/v1/gateway/{gateway}/verify',
|
|
526
|
+
|
|
527
|
+
async handler(request) {
|
|
528
|
+
try {
|
|
529
|
+
let gatewayObject = new Gateway({ redis, gateway: request.params.gateway, secret: await getSecret() });
|
|
530
|
+
let gatewayData = await gatewayObject.loadGatewayData();
|
|
531
|
+
|
|
532
|
+
// Only ever with the stored settings: the stored password goes to the host it was
|
|
533
|
+
// stored for, and nowhere a request could name
|
|
534
|
+
let verifyResult = await verifyAccountInfo(
|
|
535
|
+
redis,
|
|
536
|
+
{ smtp: gatewaySmtpConfig(gatewayData) },
|
|
537
|
+
request.logger.child({ gateway: request.params.gateway, action: 'verify-gateway' })
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
return verifyResult.smtp;
|
|
541
|
+
} catch (err) {
|
|
542
|
+
handleError(request, err);
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
options: {
|
|
546
|
+
description: 'Verify SMTP gateway',
|
|
547
|
+
notes: 'Connects to the SMTP server of a stored gateway with its stored settings and credentials, and reports whether the connection and the authentication succeeded. Nothing is sent and nothing is stored.',
|
|
548
|
+
tags: ['api', 'SMTP Gateway'],
|
|
549
|
+
|
|
550
|
+
plugins: {
|
|
551
|
+
mcp: {
|
|
552
|
+
name: 'verify_gateway',
|
|
553
|
+
title: 'Check SMTP gateway',
|
|
554
|
+
description:
|
|
555
|
+
'Check that a stored SMTP gateway still connects and authenticates, with its stored settings and credentials. Nothing is sent or changed. Use it when deliveries through the gateway fail.'
|
|
556
|
+
},
|
|
557
|
+
openapi: {
|
|
558
|
+
'x-ee-impact': IMPACT.READONLY,
|
|
559
|
+
responses: apiResponses('Returns the result of the connection check.', 400, 401, 403, 404, 429, 500)
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
|
|
563
|
+
auth: {
|
|
564
|
+
strategy: 'api-token',
|
|
565
|
+
mode: 'required'
|
|
566
|
+
},
|
|
567
|
+
cors: CORS_CONFIG,
|
|
568
|
+
|
|
569
|
+
validate: {
|
|
570
|
+
options: {
|
|
571
|
+
stripUnknown: false,
|
|
572
|
+
abortEarly: false,
|
|
573
|
+
convert: true
|
|
574
|
+
},
|
|
575
|
+
failAction,
|
|
576
|
+
|
|
577
|
+
params: Joi.object({
|
|
578
|
+
gateway: Joi.string().max(256).required().example('example').description('Gateway ID')
|
|
579
|
+
}).label('VerifyGatewayRequest')
|
|
580
|
+
},
|
|
581
|
+
|
|
582
|
+
response: {
|
|
583
|
+
schema: verifyResultSchema('Smtp', '535 Authentication failed'),
|
|
584
|
+
failAction: 'log'
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
async function init(args) {
|
|
591
|
+
const { server } = args;
|
|
592
|
+
|
|
593
|
+
registerListGateways(server, args);
|
|
594
|
+
registerGetGateway(server, args);
|
|
595
|
+
registerCreateGateway(server, args);
|
|
596
|
+
registerUpdateGateway(server, args);
|
|
597
|
+
registerDeleteGateway(server, args);
|
|
598
|
+
registerVerifyGateway(server, args);
|
|
599
|
+
}
|
|
600
|
+
|
|
503
601
|
module.exports = init;
|
package/lib/api-routes/index.js
CHANGED
|
@@ -24,6 +24,7 @@ const statsRoutes = require('./stats-routes');
|
|
|
24
24
|
const licenseRoutes = require('./license-routes');
|
|
25
25
|
const outboxRoutes = require('./outbox-routes');
|
|
26
26
|
const webhookRouteRoutes = require('./webhook-route-routes');
|
|
27
|
+
const webhookDeliveryRoutes = require('./webhook-delivery-routes');
|
|
27
28
|
const oauth2AppRoutes = require('./oauth2-app-routes');
|
|
28
29
|
const gatewayRoutes = require('./gateway-routes');
|
|
29
30
|
const deliveryTestRoutes = require('./delivery-test-routes');
|
|
@@ -130,6 +131,9 @@ async function registerApiRoutes(args) {
|
|
|
130
131
|
// setup webhook route management routes
|
|
131
132
|
await webhookRouteRoutes({ server, CORS_CONFIG });
|
|
132
133
|
|
|
134
|
+
// setup failed webhook delivery routes
|
|
135
|
+
await webhookDeliveryRoutes({ server, CORS_CONFIG });
|
|
136
|
+
|
|
133
137
|
// setup OAuth2 application routes
|
|
134
138
|
await oauth2AppRoutes({ server, call, CORS_CONFIG, OAuth2ProviderSchema });
|
|
135
139
|
|
|
@@ -28,7 +28,7 @@ async function init(args) {
|
|
|
28
28
|
},
|
|
29
29
|
options: {
|
|
30
30
|
description: 'Request license info',
|
|
31
|
-
notes: '
|
|
31
|
+
notes: 'Returns the license this instance runs with: whether one is active, who it was issued to and when it expires.',
|
|
32
32
|
tags: ['api', 'License'],
|
|
33
33
|
|
|
34
34
|
plugins: {
|
|
@@ -74,7 +74,7 @@ async function init(args) {
|
|
|
74
74
|
},
|
|
75
75
|
options: {
|
|
76
76
|
description: 'Remove license',
|
|
77
|
-
notes: '
|
|
77
|
+
notes: 'Removes the active license. The instance continues without one.',
|
|
78
78
|
tags: ['api', 'License'],
|
|
79
79
|
|
|
80
80
|
plugins: {
|
|
@@ -32,8 +32,8 @@ function throwMailboxError(request, err) {
|
|
|
32
32
|
throw error;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
const {
|
|
35
|
+
function registerListMailboxes(server, args) {
|
|
36
|
+
const { call, CORS_CONFIG, FLAG_SORT_ORDER } = args;
|
|
37
37
|
|
|
38
38
|
server.route({
|
|
39
39
|
method: 'GET',
|
|
@@ -75,7 +75,7 @@ async function init(args) {
|
|
|
75
75
|
|
|
76
76
|
options: {
|
|
77
77
|
description: 'List mailboxes',
|
|
78
|
-
notes: 'Lists
|
|
78
|
+
notes: 'Lists every folder of the account with its path, special-use flag and subscription state, and optionally its message counters.',
|
|
79
79
|
tags: ['api', 'Mailbox'],
|
|
80
80
|
|
|
81
81
|
plugins: {
|
|
@@ -130,6 +130,10 @@ async function init(args) {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function registerCreateMailbox(server, args) {
|
|
136
|
+
const { call, CORS_CONFIG } = args;
|
|
133
137
|
|
|
134
138
|
server.route({
|
|
135
139
|
method: 'POST',
|
|
@@ -153,10 +157,16 @@ async function init(args) {
|
|
|
153
157
|
|
|
154
158
|
options: {
|
|
155
159
|
description: 'Create mailbox',
|
|
156
|
-
notes: '
|
|
160
|
+
notes: 'Creates a folder at the given path, a missing parent folder included. The path can be given as a list of names, which the server joins with its own separator.',
|
|
157
161
|
tags: ['api', 'Mailbox'],
|
|
158
162
|
|
|
159
163
|
plugins: {
|
|
164
|
+
mcp: {
|
|
165
|
+
name: 'create_mailbox',
|
|
166
|
+
title: 'Create mailbox',
|
|
167
|
+
description:
|
|
168
|
+
'Create a folder. Give the path as a list of names from the top level down (["Projects", "2026"]) so the server joins them with its own separator; a missing parent is created too. The response carries the full path that list_messages and move_message take.'
|
|
169
|
+
},
|
|
160
170
|
openapi: {
|
|
161
171
|
responses: apiResponses('Returns the created folder and its path.', 400, 401, 403, 404, 429, 500, 503)
|
|
162
172
|
}
|
|
@@ -201,6 +211,10 @@ async function init(args) {
|
|
|
201
211
|
}
|
|
202
212
|
}
|
|
203
213
|
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function registerModifyMailbox(server, args) {
|
|
217
|
+
const { call, CORS_CONFIG } = args;
|
|
204
218
|
|
|
205
219
|
server.route({
|
|
206
220
|
method: 'PUT',
|
|
@@ -228,6 +242,12 @@ async function init(args) {
|
|
|
228
242
|
tags: ['api', 'Mailbox'],
|
|
229
243
|
|
|
230
244
|
plugins: {
|
|
245
|
+
mcp: {
|
|
246
|
+
name: 'update_mailbox',
|
|
247
|
+
title: 'Rename or update mailbox',
|
|
248
|
+
description:
|
|
249
|
+
'Rename or move a folder (newPath, as a list of names from the top level down), or change whether it is subscribed. `path` is the current path from list_mailboxes. The messages move with the folder; list them again under the new path for their current ids.'
|
|
250
|
+
},
|
|
231
251
|
openapi: {
|
|
232
252
|
responses: apiResponses('Returns the renamed folder with its old and new paths.', 400, 401, 403, 404, 429, 500, 503)
|
|
233
253
|
}
|
|
@@ -284,6 +304,10 @@ async function init(args) {
|
|
|
284
304
|
}
|
|
285
305
|
}
|
|
286
306
|
});
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function registerDeleteMailbox(server, args) {
|
|
310
|
+
const { call, CORS_CONFIG } = args;
|
|
287
311
|
|
|
288
312
|
server.route({
|
|
289
313
|
method: 'DELETE',
|
|
@@ -309,10 +333,16 @@ async function init(args) {
|
|
|
309
333
|
|
|
310
334
|
options: {
|
|
311
335
|
description: 'Delete mailbox',
|
|
312
|
-
notes: '
|
|
336
|
+
notes: 'Deletes a folder together with every message in it.',
|
|
313
337
|
tags: ['api', 'Mailbox'],
|
|
314
338
|
|
|
315
339
|
plugins: {
|
|
340
|
+
mcp: {
|
|
341
|
+
name: 'delete_mailbox',
|
|
342
|
+
title: 'Delete mailbox',
|
|
343
|
+
description:
|
|
344
|
+
'Delete a folder by its path from list_mailboxes - confirm with the user before calling this. On an IMAP account the folder goes with every message in it, and nothing is kept in Trash. On a Gmail API account the label is removed and the messages stay in the mailbox under their other labels.'
|
|
345
|
+
},
|
|
316
346
|
openapi: {
|
|
317
347
|
'x-ee-impact': IMPACT.DESTRUCTIVE,
|
|
318
348
|
responses: apiResponses('Returns the deleted folder path.', 400, 401, 403, 404, 429, 500, 503)
|
|
@@ -357,4 +387,13 @@ async function init(args) {
|
|
|
357
387
|
});
|
|
358
388
|
}
|
|
359
389
|
|
|
390
|
+
async function init(args) {
|
|
391
|
+
const { server } = args;
|
|
392
|
+
|
|
393
|
+
registerListMailboxes(server, args);
|
|
394
|
+
registerCreateMailbox(server, args);
|
|
395
|
+
registerModifyMailbox(server, args);
|
|
396
|
+
registerDeleteMailbox(server, args);
|
|
397
|
+
}
|
|
398
|
+
|
|
360
399
|
module.exports = init;
|