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.
Files changed (164) hide show
  1. package/.ncurc.js +29 -9
  2. package/.prettierignore +5 -1
  3. package/.prettierrc.js +2 -0
  4. package/.release-please-manifest.json +1 -1
  5. package/CHANGELOG.md +107 -0
  6. package/Dockerfile +20 -1
  7. package/ENVIRONMENT.md +139 -0
  8. package/README.md +2 -2
  9. package/bin/emailengine.js +434 -408
  10. package/config/default.toml +2 -0
  11. package/copy-static-files.sh +41 -14
  12. package/data/google-crawlers.json +1 -1
  13. package/data/public_suffix_list.dat +16563 -0
  14. package/eslint.config.js +81 -99
  15. package/lib/account-assignment.js +19 -0
  16. package/lib/account.js +230 -170
  17. package/lib/api-error-codes.js +49 -0
  18. package/lib/api-reference/format.js +4 -3
  19. package/lib/api-reference/model.js +6 -1
  20. package/lib/api-routes/account-routes.js +255 -38
  21. package/lib/api-routes/blocklist-routes.js +91 -4
  22. package/lib/api-routes/delivery-test-routes.js +27 -4
  23. package/lib/api-routes/export-routes.js +28 -2
  24. package/lib/api-routes/gateway-routes.js +110 -12
  25. package/lib/api-routes/index.js +4 -0
  26. package/lib/api-routes/license-routes.js +2 -2
  27. package/lib/api-routes/mailbox-routes.js +44 -5
  28. package/lib/api-routes/message-routes.js +112 -10
  29. package/lib/api-routes/oauth2-app-routes.js +63 -23
  30. package/lib/api-routes/outbox-routes.js +97 -52
  31. package/lib/api-routes/permission-map.js +67 -7
  32. package/lib/api-routes/scoped-routes.js +74 -0
  33. package/lib/api-routes/settings-routes.js +34 -6
  34. package/lib/api-routes/stats-routes.js +5 -1
  35. package/lib/api-routes/submit-routes.js +337 -309
  36. package/lib/api-routes/template-routes.js +45 -8
  37. package/lib/api-routes/token-routes.js +152 -100
  38. package/lib/api-routes/webhook-delivery-routes.js +262 -0
  39. package/lib/api-routes/webhook-route-routes.js +132 -6
  40. package/lib/bounce-detect.js +397 -205
  41. package/lib/calendar-event.js +81 -1
  42. package/lib/consts.js +38 -45
  43. package/lib/db.js +14 -6
  44. package/lib/delivery-error.js +6 -0
  45. package/lib/deprecations.js +270 -0
  46. package/lib/email-client/base-client.js +137 -184
  47. package/lib/email-client/fallback-poll.js +62 -0
  48. package/lib/email-client/gmail-client.js +60 -22
  49. package/lib/email-client/imap/adaptive-idle-store.js +73 -0
  50. package/lib/email-client/imap/adaptive-idle.js +278 -0
  51. package/lib/email-client/imap/connection-errors.js +14 -1
  52. package/lib/email-client/imap/idle-settings.js +31 -5
  53. package/lib/email-client/imap/listing-diff.js +37 -0
  54. package/lib/email-client/imap/mailbox.js +372 -242
  55. package/lib/email-client/imap/subconnection.js +8 -30
  56. package/lib/email-client/imap/sync-operations.js +220 -127
  57. package/lib/email-client/imap-client.js +228 -164
  58. package/lib/email-client/message-builder.js +14 -79
  59. package/lib/email-client/notification-handler.js +1 -2
  60. package/lib/email-client/outlook-client.js +372 -338
  61. package/lib/email-client/smtp-pool-manager.js +16 -13
  62. package/lib/email-client/sync-state-fields.js +19 -0
  63. package/lib/encrypt.js +157 -41
  64. package/lib/enum-descriptions.js +3 -1
  65. package/lib/env-setting-overrides.js +288 -0
  66. package/lib/export-worker.js +751 -0
  67. package/lib/export.js +64 -15
  68. package/lib/gateway.js +19 -4
  69. package/lib/get-raw-email.js +25 -107
  70. package/lib/hapi-request-logger.js +107 -0
  71. package/lib/health.js +75 -0
  72. package/lib/imapproxy/imap-core/README.md +6 -5
  73. package/lib/lock-run.js +119 -0
  74. package/lib/logger-consts.js +48 -0
  75. package/lib/logger.js +1 -1
  76. package/lib/lua/z-head-scores.lua +28 -0
  77. package/lib/mcp/tools.js +37 -8
  78. package/lib/network-errors.js +1 -1
  79. package/lib/node-version.js +24 -0
  80. package/lib/notify-attachments.js +36 -0
  81. package/lib/oauth/outlook-mailbox.js +35 -0
  82. package/lib/oauth/state.js +24 -0
  83. package/lib/oauth2-apps.js +631 -656
  84. package/lib/outbox.js +184 -54
  85. package/lib/parse-message.js +3 -3
  86. package/lib/pbkdf2-phc.js +1 -1
  87. package/lib/privileged-settings.js +2 -2
  88. package/lib/queue-browser/definitions.js +11 -0
  89. package/lib/queue-browser/index.js +68 -19
  90. package/lib/queue-job-actions.js +18 -1
  91. package/lib/queue-retention.js +48 -12
  92. package/lib/queue-stats.js +11 -2
  93. package/lib/read-env-value.js +3 -0
  94. package/lib/redis-memory-warnings.js +99 -0
  95. package/lib/redis-reconnect.js +29 -0
  96. package/lib/request-timing.js +23 -0
  97. package/lib/respawn-backoff.js +35 -0
  98. package/lib/rewrite-text-nodes.js +19 -59
  99. package/lib/schemas.js +164 -40
  100. package/lib/settings.js +6 -2
  101. package/lib/smtp-auth.js +19 -1
  102. package/lib/sso.js +1 -1
  103. package/lib/swagger-options.js +1 -1
  104. package/lib/thread-diagnostics.js +63 -0
  105. package/lib/timezones.js +109 -0
  106. package/lib/tls/provision.js +6 -3
  107. package/lib/token-audit-log.js +19 -20
  108. package/lib/token-permission-view.js +7 -6
  109. package/lib/tools.js +48 -51
  110. package/lib/totp.js +2 -5
  111. package/lib/translations.js +1 -2
  112. package/lib/ui-routes/account-routes.js +475 -454
  113. package/lib/ui-routes/account-setup.js +99 -0
  114. package/lib/ui-routes/admin-config-routes.js +152 -100
  115. package/lib/ui-routes/admin-entities-routes.js +93 -21
  116. package/lib/ui-routes/auth-routes.js +90 -38
  117. package/lib/ui-routes/imap-idle-field.js +1 -1
  118. package/lib/ui-routes/internals-routes.js +5 -0
  119. package/lib/ui-routes/oauth-config-routes.js +124 -82
  120. package/lib/ui-routes/outlook-subscription-view.js +1 -1
  121. package/lib/ui-routes/overridable-fields.js +84 -0
  122. package/lib/ui-routes/queue-routes.js +8 -5
  123. package/lib/ui-routes/route-helpers.js +19 -3
  124. package/lib/ui-routes/settings-page.js +6 -0
  125. package/lib/ui-routes/tls-config-routes.js +58 -15
  126. package/lib/utils/back-off.js +82 -0
  127. package/lib/utils/decode-headers.js +3 -12
  128. package/lib/utils/filter-empty.js +20 -0
  129. package/lib/utils/int-setting.js +48 -0
  130. package/lib/utils/murmurhash3.js +66 -0
  131. package/lib/utils/public-suffix.js +122 -0
  132. package/lib/utils/random-id.js +26 -0
  133. package/lib/utils/tracking-settings.js +35 -0
  134. package/lib/utils/version.js +74 -0
  135. package/lib/web-safe-html.js +18 -105
  136. package/lib/webhook-delivery.js +461 -0
  137. package/lib/webhook-failures.js +132 -0
  138. package/lib/webhook-request.js +29 -1
  139. package/lib/webhook-routing.js +56 -0
  140. package/lib/webhook-test.js +88 -0
  141. package/lib/webhooks.js +93 -45
  142. package/lib/worker-rpc-error.js +2 -1
  143. package/package.json +37 -38
  144. package/sbom.json +7902 -1
  145. package/server.js +784 -518
  146. package/static/js/ace/ace.js +1 -1
  147. package/static/licenses.html +225 -1060
  148. package/translations/messages.pot +62 -63
  149. package/views/config/ai.hbs +1 -1
  150. package/views/config/security.hbs +24 -2
  151. package/views/config/service.hbs +47 -0
  152. package/views/config/webhooks.hbs +36 -0
  153. package/views/internals/index.hbs +8 -0
  154. package/views/partials/queue_retention_note.hbs +12 -8
  155. package/views/partials/ui/env-managed-alert.hbs +16 -7
  156. package/views/partials/webhook_form.hbs +1 -1
  157. package/views/suppression-lists/index.hbs +1 -1
  158. package/workers/api.js +840 -611
  159. package/workers/export.js +17 -632
  160. package/workers/imap.js +13 -0
  161. package/workers/smtp.js +9 -11
  162. package/workers/submit.js +1 -1
  163. package/workers/webhooks.js +18 -448
  164. 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
- async function init(args) {
13
- const { server, CORS_CONFIG } = args;
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
- async function init(args) {
39
- const { server, call, CORS_CONFIG } = args;
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 registered gateways',
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: 'Registers a new SMP gateway',
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: 'Updates gateway information',
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: 'Delete SMTP gateway data',
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;
@@ -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: 'Get active license information',
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: 'Remove registered active license',
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
- async function init(args) {
36
- const { server, call, CORS_CONFIG, FLAG_SORT_ORDER } = args;
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 all available mailboxes',
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: 'Create new mailbox folder',
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: 'Delete existing mailbox folder',
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;