emailengine-app 2.77.0 → 2.79.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 (189) hide show
  1. package/.github/workflows/test.yml +80 -0
  2. package/.ncurc.js +23 -13
  3. package/.release-please-manifest.json +1 -1
  4. package/CHANGELOG.md +60 -0
  5. package/bin/emailengine.js +1 -1
  6. package/config/e2e.toml +2 -1
  7. package/config/test.toml +2 -1
  8. package/data/google-crawlers.json +1 -1
  9. package/encrypt.js +1 -1
  10. package/lib/account/expected-identity.js +88 -0
  11. package/lib/account.js +145 -61
  12. package/lib/api-reference/format.js +105 -4
  13. package/lib/api-reference/index.js +24 -7
  14. package/lib/api-reference/model.js +148 -21
  15. package/lib/api-reference/schema-tree.js +282 -28
  16. package/lib/api-routes/account-routes.js +99 -36
  17. package/lib/api-routes/behavior-notes.js +3 -0
  18. package/lib/api-routes/blocklist-routes.js +21 -47
  19. package/lib/api-routes/chat-routes.js +10 -12
  20. package/lib/api-routes/delivery-test-routes.js +6 -26
  21. package/lib/api-routes/export-routes.js +2 -0
  22. package/lib/api-routes/gateway-routes.js +52 -11
  23. package/lib/api-routes/license-routes.js +2 -0
  24. package/lib/api-routes/mailbox-routes.js +29 -26
  25. package/lib/api-routes/message-routes.js +27 -21
  26. package/lib/api-routes/oauth2-app-routes.js +11 -29
  27. package/lib/api-routes/operation-impact.js +80 -0
  28. package/lib/api-routes/outbox-routes.js +15 -5
  29. package/lib/api-routes/permission-map.js +397 -0
  30. package/lib/api-routes/route-helpers.js +223 -9
  31. package/lib/api-routes/route-metadata.js +28 -0
  32. package/lib/api-routes/settings-routes.js +30 -25
  33. package/lib/api-routes/stats-routes.js +2 -2
  34. package/lib/api-routes/submit-routes.js +53 -31
  35. package/lib/api-routes/template-routes.js +3 -0
  36. package/lib/api-routes/token-routes.js +319 -33
  37. package/lib/api-routes/webhook-route-routes.js +14 -4
  38. package/lib/append-list.js +3 -14
  39. package/lib/arf-detect.js +23 -1
  40. package/lib/auth-token.js +80 -8
  41. package/lib/autodetect-imap-settings.js +40 -16
  42. package/lib/base32.js +30 -0
  43. package/lib/bounce-detect.js +182 -62
  44. package/lib/consts.js +10 -0
  45. package/lib/db.js +20 -2
  46. package/lib/delivery-error.js +30 -1
  47. package/lib/egress-filter.js +89 -8
  48. package/lib/email-client/base-client.js +35 -113
  49. package/lib/email-client/gmail-client.js +22 -13
  50. package/lib/email-client/imap/listing-diff.js +3 -3
  51. package/lib/email-client/imap/mailbox.js +28 -93
  52. package/lib/email-client/imap/subconnection.js +10 -7
  53. package/lib/email-client/imap/sync-operations.js +46 -46
  54. package/lib/email-client/imap-client.js +39 -28
  55. package/lib/email-client/message-builder.js +15 -15
  56. package/lib/email-client/notification-handler.js +1 -1
  57. package/lib/email-client/outlook/graph-api.js +10 -4
  58. package/lib/email-client/outlook-client.js +54 -55
  59. package/lib/email-client/smtp-pool-manager.js +1 -1
  60. package/lib/enum-descriptions.js +92 -2
  61. package/lib/export.js +2 -2
  62. package/lib/field-usage.js +133 -0
  63. package/lib/gateway.js +2 -2
  64. package/lib/get-raw-email.js +1 -1
  65. package/lib/imapproxy/imap-core/lib/commands/authenticate-plain.js +3 -3
  66. package/lib/imapproxy/imap-core/lib/commands/id.js +2 -13
  67. package/lib/imapproxy/imap-core/lib/commands/starttls.js +1 -1
  68. package/lib/imapproxy/imap-core/lib/imap-command.js +21 -5
  69. package/lib/imapproxy/imap-core/lib/imap-connection.js +17 -7
  70. package/lib/imapproxy/imap-core/lib/imap-server.js +2 -2
  71. package/lib/imapproxy/imap-server.js +40 -10
  72. package/lib/license-beacon.js +5 -10
  73. package/lib/lists.js +49 -1
  74. package/lib/llm-pre-process.js +6 -6
  75. package/lib/logger.js +5 -1
  76. package/lib/metrics-collector.js +2 -2
  77. package/lib/msgpack.js +62 -0
  78. package/lib/oauth/decode-jwt-payload.js +39 -0
  79. package/lib/oauth/gmail.js +9 -12
  80. package/lib/oauth/mail-ru.js +5 -7
  81. package/lib/oauth/outlook-identity.js +61 -0
  82. package/lib/oauth/outlook.js +9 -9
  83. package/lib/oauth/pubsub/google.js +25 -10
  84. package/lib/oauth/retry-setup.js +38 -0
  85. package/lib/oauth/scope-checker.js +1 -1
  86. package/lib/oauth2-apps.js +224 -295
  87. package/lib/openapi/build-document.js +15 -7
  88. package/lib/openapi/joi-schema.js +20 -0
  89. package/lib/outbox.js +145 -14
  90. package/lib/pre-process.js +9 -9
  91. package/lib/queue-stats.js +49 -0
  92. package/lib/read-env-value.js +37 -0
  93. package/lib/reconnection-manager.js +2 -2
  94. package/lib/rewrite-text-nodes.js +4 -3
  95. package/lib/routes-ui.js +4 -0
  96. package/lib/schemas.js +223 -155
  97. package/lib/settings.js +84 -5
  98. package/lib/sub-script.js +2 -1
  99. package/lib/swagger-options.js +2 -1
  100. package/lib/templates.js +5 -5
  101. package/lib/threads.js +2 -2
  102. package/lib/token-audit-log.js +208 -0
  103. package/lib/token-permission-view.js +219 -0
  104. package/lib/token-permissions.js +172 -0
  105. package/lib/tokens.js +100 -16
  106. package/lib/tools.js +259 -85
  107. package/lib/totp.js +67 -0
  108. package/lib/ui-routes/account-routes.js +122 -26
  109. package/lib/ui-routes/admin-config-routes.js +20 -17
  110. package/lib/ui-routes/admin-entities-routes.js +66 -22
  111. package/lib/ui-routes/auth-routes.js +36 -48
  112. package/lib/ui-routes/export-routes.js +10 -4
  113. package/lib/ui-routes/oauth-config-routes.js +5 -5
  114. package/lib/ui-routes/reference-routes.js +11 -8
  115. package/lib/ui-routes/route-helpers.js +79 -2
  116. package/lib/ui-routes/settings-page.js +1 -1
  117. package/lib/ui-routes/smtp-test-routes.js +1 -1
  118. package/lib/ui-routes/suppression-list-routes.js +294 -0
  119. package/lib/ui-routes/unsubscribe-routes.js +19 -29
  120. package/lib/utils/is-email.js +34 -0
  121. package/lib/utils/network.js +2 -2
  122. package/lib/utils/to-camel-case.js +17 -0
  123. package/lib/web-safe-html.js +1 -1
  124. package/lib/webhook-egress.js +37 -0
  125. package/lib/webhook-routing.js +80 -0
  126. package/lib/webhooks.js +21 -15
  127. package/package.json +26 -27
  128. package/sbom.json +1 -0
  129. package/server.js +81 -42
  130. package/static/css/flyonui.css +1 -1
  131. package/static/css/public.css +3 -0
  132. package/static/css/src/app.tailwind.css +159 -9
  133. package/static/js/app.js +69 -0
  134. package/static/js/reference.js +741 -10
  135. package/static/js/ui.js +43 -0
  136. package/static/licenses.html +698 -1590
  137. package/translations/README.md +64 -0
  138. package/translations/de.mo +0 -0
  139. package/translations/de.po +164 -120
  140. package/translations/en.po +200 -161
  141. package/translations/et.mo +0 -0
  142. package/translations/et.po +163 -120
  143. package/translations/fr.mo +0 -0
  144. package/translations/fr.po +163 -120
  145. package/translations/ja.mo +0 -0
  146. package/translations/ja.po +163 -120
  147. package/translations/messages.pot +94 -64
  148. package/translations/nl.mo +0 -0
  149. package/translations/nl.po +164 -120
  150. package/translations/pl.mo +0 -0
  151. package/translations/pl.po +163 -120
  152. package/views/account-identity-error.hbs +34 -0
  153. package/views/accounts/account.hbs +69 -7
  154. package/views/accounts/browse.hbs +18 -35
  155. package/views/accounts/edit.hbs +1 -0
  156. package/views/accounts/register/imap.hbs +12 -2
  157. package/views/config/logging.hbs +6 -0
  158. package/views/config/oauth/app.hbs +0 -2
  159. package/views/config/security.hbs +13 -0
  160. package/views/layout/app.hbs +29 -5
  161. package/views/oauth-scope-error.hbs +1 -1
  162. package/views/partials/oauth_form.hbs +0 -15
  163. package/views/partials/reference/disclosure.hbs +8 -2
  164. package/views/partials/reference/nav.hbs +36 -9
  165. package/views/partials/reference/operation.hbs +48 -14
  166. package/views/partials/reference/params.hbs +17 -1
  167. package/views/partials/reference/schema-node.hbs +112 -54
  168. package/views/partials/reference/schema-tools.hbs +25 -0
  169. package/views/partials/reference/token-alert.hbs +35 -10
  170. package/views/partials/reference/try-it.hbs +84 -11
  171. package/views/partials/side_menu.hbs +1 -0
  172. package/views/partials/ui/checkbox.hbs +2 -2
  173. package/views/partials/ui/tabs.hbs +7 -1
  174. package/views/reference/index.hbs +1 -1
  175. package/views/reference/token.hbs +4 -0
  176. package/views/suppression-lists/index.hbs +85 -0
  177. package/views/suppression-lists/list.hbs +87 -0
  178. package/views/templates/index.hbs +8 -2
  179. package/views/tokens/index.hbs +31 -4
  180. package/views/tokens/new.hbs +324 -2
  181. package/workers/api.js +299 -140
  182. package/workers/documents.js +46 -26
  183. package/workers/export.js +20 -8
  184. package/workers/imap-proxy.js +2 -2
  185. package/workers/imap.js +13 -7
  186. package/workers/smtp.js +13 -7
  187. package/workers/submit.js +41 -31
  188. package/workers/webhooks.js +60 -37
  189. package/lib/feature-flags.js +0 -48
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ // Where a route keeps the metadata that is about its documentation and its permissions rather than
4
+ // about serving the request: `plugins.openapi` in the route definition.
5
+ //
6
+ // Its own module because two readers need it and neither should own it. lib/openapi/build-document.js
7
+ // publishes what it finds there, and ./permission-map.js reads `x-ee-impact` out of it at request
8
+ // time to resolve what a token needs. Keeping the accessor in either would have the other spell the
9
+ // slot out again, and one of them feeds access control: rename the key with two independent readers
10
+ // and the second starts seeing an empty object, which downgrades every declared impact to the method
11
+ // default with nothing failing.
12
+ //
13
+ // It sits under lib/api-routes/ rather than lib/openapi/ so the dependency runs one way. The
14
+ // generator reads route metadata; route modules do not read the generator.
15
+
16
+ const PLUGIN_OPTIONS_KEY = 'openapi';
17
+
18
+ /**
19
+ * The documentation and permission metadata a route declares.
20
+ *
21
+ * @param {Object} route - a `server.table()` entry, or a live `request.route`
22
+ * @returns {Object} the route's `plugins.openapi`, or an empty object when it declares none
23
+ */
24
+ function pluginOptions(route) {
25
+ return (route && route.settings && route.settings.plugins && route.settings.plugins[PLUGIN_OPTIONS_KEY]) || {};
26
+ }
27
+
28
+ module.exports = { pluginOptions };
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const Joi = require('joi');
4
- const { redis, documentsQueue, notifyQueue, submitQueue } = require('../db');
4
+ const { QUEUES_BY_NAME } = require('../db');
5
5
  const settings = require('../settings');
6
6
  const consts = require('../consts');
7
- const { REDIS_PREFIX } = consts;
8
7
  const { failAction } = require('../tools');
9
- const { handleError } = require('./route-helpers');
8
+ const { queueStats } = require('../queue-stats');
9
+ const { handleError, maskSecrets } = require('./route-helpers');
10
10
  const { settingsSchema, settingsQuerySchema, apiResponses, ENUM_DESCRIPTIONS } = require('../schemas');
11
11
 
12
12
  // Response variant of the settings schema. Secret values are masked and returned as booleans,
@@ -59,6 +59,15 @@ async function init(args) {
59
59
  values[key] = value;
60
60
  }
61
61
  }
62
+
63
+ // The global equivalents of the credential-bearing account fields. encryptedKeys above
64
+ // covers what is encrypted at rest, which is not the same set: proxyUrl, httpProxyUrl,
65
+ // webhooks and webhooksCustomHeaders are stored in the clear and were returned in full,
66
+ // so this endpoint disclosed exactly what the account getters were masking. It sits in
67
+ // the never-grantable admin group, so no narrowed token reaches it - but leaving the
68
+ // asymmetry here is how the next reader learns the wrong pattern.
69
+ maskSecrets(values);
70
+
62
71
  return values;
63
72
  },
64
73
  options: {
@@ -165,30 +174,25 @@ async function init(args) {
165
174
  queue
166
175
  };
167
176
 
168
- const [resActive, resDelayed, resPaused, resWaiting, resMeta] = await redis
169
- .multi()
170
- .llen(`${REDIS_PREFIX}bull:${queue}:active`)
171
- .zcard(`${REDIS_PREFIX}bull:${queue}:delayed`)
172
- .llen(`${REDIS_PREFIX}bull:${queue}:paused`)
173
- .llen(`${REDIS_PREFIX}bull:${queue}:wait`)
174
- .hget(`${REDIS_PREFIX}bull:${queue}:meta`, 'paused')
175
- .exec();
176
-
177
- if (resActive[0] || resDelayed[0] || resPaused[0] || resWaiting[0]) {
178
- // counting failed
177
+ let stats;
178
+ try {
179
+ stats = await queueStats(QUEUES_BY_NAME[queue]);
180
+ } catch (countErr) {
179
181
  let err = new Error('Failed to count queue length');
180
182
  err.statusCode = 500;
183
+ err.cause = countErr;
181
184
  throw err;
182
185
  }
183
186
 
184
187
  values.jobs = {
185
- active: Number(resActive[1]) || 0,
186
- delayed: Number(resDelayed[1]) || 0,
187
- paused: Number(resPaused[1]) || 0,
188
- waiting: Number(resWaiting[1]) || 0
188
+ active: stats.active,
189
+ delayed: stats.delayed,
190
+ // Reported for compatibility only - see the response schema below
191
+ paused: stats.paused,
192
+ waiting: stats.waiting
189
193
  };
190
194
 
191
- values.paused = !!Number(resMeta[1]) || false;
195
+ values.paused = stats.isPaused;
192
196
 
193
197
  return values;
194
198
  } catch (err) {
@@ -246,7 +250,12 @@ async function init(args) {
246
250
  jobs: Joi.object({
247
251
  active: Joi.number().integer().example(123).description('Jobs that are currently being processed'),
248
252
  delayed: Joi.number().integer().example(123).description('Jobs that are processed in the future'),
249
- paused: Joi.number().integer().example(123).description('Jobs that would be processed once queue processing is resumed'),
253
+ paused: Joi.number()
254
+ .integer()
255
+ .example(0)
256
+ .description(
257
+ 'Always 0. BullMQ 6 no longer parks jobs in a separate paused list, so jobs held by a paused queue are counted as waiting. Kept so existing clients still see the key'
258
+ ),
250
259
  waiting: Joi.number()
251
260
  .integer()
252
261
  .example(123)
@@ -267,11 +276,7 @@ async function init(args) {
267
276
  try {
268
277
  let queue = request.params.queue;
269
278
 
270
- let queueObj = {
271
- documents: documentsQueue,
272
- notify: notifyQueue,
273
- submit: submitQueue
274
- }[queue];
279
+ let queueObj = QUEUES_BY_NAME[queue];
275
280
 
276
281
  let values = {
277
282
  queue
@@ -72,14 +72,14 @@ async function init(args) {
72
72
  key: Joi.string().example('maxmemory-policy').description('Warning identifier'),
73
73
  color: Joi.string().example('warning').description('Severity indicator'),
74
74
  title: Joi.string().example('Unsafe Redis eviction policy').description('Warning title'),
75
- details: Joi.array().items(Joi.string()).description('Warning details')
75
+ details: Joi.array().items(Joi.string().example('maxmemory-policy is allkeys-lru')).description('Warning details')
76
76
  })
77
77
  .unknown()
78
78
  .label('RedisWarningEntry')
79
79
  )
80
80
  .description('Warnings about the Redis configuration')
81
81
  .label('RedisWarnings'),
82
- redisPing: Joi.number().description('Redis latency in milliseconds'),
82
+ redisPing: Joi.number().example(1.2).description('Redis latency in milliseconds'),
83
83
  imapflow: Joi.string().example('1.0.188').description('ImapFlow version'),
84
84
  bullmq: Joi.string().example('5.0.0').description('BullMQ version'),
85
85
  arch: Joi.string().example('arm64').description('CPU architecture of the host'),
@@ -5,8 +5,10 @@ const { redis } = require('../db');
5
5
  const { Account } = require('../account');
6
6
  const getSecret = require('../get-secret');
7
7
  const { failAction } = require('../tools');
8
- const { handleError } = require('./route-helpers');
8
+ const { handleError, assertNoNetworkOverride } = require('./route-helpers');
9
9
  const BEHAVIOR = require('./behavior-notes');
10
+ const { IMPACT } = require('./operation-impact');
11
+ const { FIELD_USAGE } = require('../field-usage');
10
12
  const {
11
13
  messageReferenceSchema,
12
14
  fromAddressSchema,
@@ -36,7 +38,12 @@ const deliveryAttemptsSchema = Joi.number().integer().example(10).description('H
36
38
  const gatewaySchema = Joi.string().max(256).example('example').description('Optional SMTP gateway ID for message routing').label('MessageGateway');
37
39
 
38
40
  const dsnSchema = Joi.object({
39
- id: Joi.string().trim().empty('').max(256).description('The envelope identifier that would be included in the response (ENVID)'),
41
+ id: Joi.string()
42
+ .trim()
43
+ .empty('')
44
+ .max(256)
45
+ .example('order-4815-notify')
46
+ .description('The envelope identifier that would be included in the response (ENVID)'),
40
47
  return: Joi.string()
41
48
  .trim()
42
49
  .empty('')
@@ -47,12 +54,19 @@ const dsnSchema = Joi.object({
47
54
  notify: Joi.array()
48
55
  .single()
49
56
  .items(Joi.string().valid('never', 'success', 'failure', 'delay').meta({ enumDescriptions: ENUM_DESCRIPTIONS.dsnNotify }).label('NotifyEntry'))
57
+ .example(['failure', 'delay'])
50
58
  .description('Defines the conditions under which a DSN response should be sent')
51
59
  .label('DsnNotify'),
52
- recipient: Joi.string().trim().empty('').email().description('The email address the DSN should be sent (ORCPT)')
60
+ recipient: Joi.string().trim().empty('').email().example('bounces@example.com').description('The email address the DSN should be sent (ORCPT)')
53
61
  }).description('Request DSN notifications');
54
62
 
55
- const proxySchema = settingsSchema.proxyUrl.description('Optional proxy URL to use when connecting to the SMTP server');
63
+ // Refused for a token that carries a `permissions` record, see assertNoNetworkOverride() - the
64
+ // override decides where a session carrying the account's SMTP credentials connects, so it is not
65
+ // something a narrowed credential may set. Said in the description because the alternative is a 403
66
+ // that reads as a permission bug.
67
+ const proxySchema = settingsSchema.proxyUrl.description(
68
+ 'Optional proxy URL to use when connecting to the SMTP server. A token with restricted permissions can not set this - it redirects a session that carries the account credentials'
69
+ );
56
70
 
57
71
  const localAddressSchema = ipSchema.description('Optional local IP address to bind to when connecting to the SMTP server');
58
72
 
@@ -61,7 +75,8 @@ const idempotencyResponseSchema = Joi.object({
61
75
  status: Joi.string()
62
76
  .valid('MISS', 'HIT')
63
77
  .example('MISS')
64
- .description('Whether the response was generated now (MISS) or returned from the idempotency cache (HIT)')
78
+ .description('Whether this response was produced now or replayed from the idempotency cache')
79
+ .meta({ enumDescriptions: ENUM_DESCRIPTIONS.idempotencyStatus })
65
80
  })
66
81
  .description('Idempotency info, present when an Idempotency-Key header was used')
67
82
  .label('ResponseIdempotency');
@@ -83,6 +98,8 @@ async function init(args) {
83
98
  });
84
99
 
85
100
  try {
101
+ assertNoNetworkOverride(request);
102
+
86
103
  return await accountObject.queueMessage(request.payload, {
87
104
  source: 'api',
88
105
  idempotencyKey: request.headers['idempotency-key'],
@@ -108,6 +125,7 @@ async function init(args) {
108
125
 
109
126
  plugins: {
110
127
  openapi: {
128
+ 'x-ee-impact': IMPACT.SENDS,
111
129
  'x-ee-behavior': [BEHAVIOR.QUEUED_DELIVERY, BEHAVIOR.SENT_FOLDER_UPLOAD],
112
130
  responses: apiResponses(
113
131
  'Returns the queue ID the message was accepted under. Delivery happens asynchronously - a 200 means queued, not sent.',
@@ -150,9 +168,8 @@ async function init(args) {
150
168
  .truthy('Y', 'true', '1')
151
169
  .falsy('N', 'false', 0)
152
170
  .default(false)
153
- .description(
154
- 'For MS Graph accounts: If true, uses structured JSON format (respects from field for shared mailboxes, breaks calendar invites and special MIME types). If false, sends as raw MIME (preserves calendar invites, ignores from field). Default is false (raw MIME).'
155
- )
171
+ .description('For MS Graph accounts: send as structured JSON instead of raw MIME')
172
+ .meta({ usage: FIELD_USAGE.useStructuredFormat })
156
173
  }).label('SubmitQuery'),
157
174
 
158
175
  headers: submitHeadersSchema,
@@ -164,9 +181,8 @@ async function init(args) {
164
181
  from: Joi.string().email().allow('').example('sender@example.com'),
165
182
  to: Joi.array().items(Joi.string().email().required().example('recipient@example.com')).single().label('SmtpEnvelopeTo')
166
183
  })
167
- .description(
168
- "An optional object specifying the SMTP envelope used during email transmission. If not provided, the envelope is automatically derived from the email's message headers. This is useful when you need the envelope addresses to differ from those in the email headers."
169
- )
184
+ .description('An optional object specifying the SMTP envelope used during email transmission')
185
+ .meta({ usage: FIELD_USAGE.messageEnvelope })
170
186
  .label('SMTPEnvelope')
171
187
  .when('mailMerge', {
172
188
  is: Joi.exist().not(false, null),
@@ -177,9 +193,8 @@ async function init(args) {
177
193
  .base64()
178
194
  .max(MAX_ATTACHMENT_SIZE)
179
195
  .example('TUlNRS1WZXJzaW9uOiAxLjANClN1YmplY3Q6IGhlbGxvIHdvcmxkDQoNCkhlbGxvIQ0K')
180
- .description(
181
- 'A Base64-encoded email message in RFC 822 format. If you provide other fields along with raw, those fields will override the corresponding values in the raw message.'
182
- )
196
+ .description('A Base64-encoded email message in RFC 822 format')
197
+ .meta({ usage: FIELD_USAGE.messageRaw })
183
198
  .label('RFC822Raw')
184
199
  .when('mailMerge', {
185
200
  is: Joi.exist().not(false, null),
@@ -237,12 +252,16 @@ async function init(args) {
237
252
  format: Joi.string()
238
253
  .valid('html', 'markdown')
239
254
  .default('html')
240
- .description('Markup language for HTML ("html" or "markdown")')
255
+ .description('Markup language the template is written in')
256
+ .meta({ enumDescriptions: ENUM_DESCRIPTIONS.renderFormat })
241
257
  .label('RenderFormat'),
242
- params: Joi.object().label('RenderValues').description('An object of variables for the template renderer')
258
+ params: Joi.object()
259
+ .label('RenderValues')
260
+ .example({ firstName: 'Nyan', orderId: '4815' })
261
+ .description('An object of variables for the template renderer')
243
262
  })
244
263
  .allow(false)
245
- .description('Template rendering options')
264
+ .description('Template rendering options. Set to `false` to send the template as-is, without rendering it.')
246
265
  .when('mailMerge', {
247
266
  is: Joi.exist().not(false, null),
248
267
  then: Joi.forbidden('y')
@@ -254,7 +273,10 @@ async function init(args) {
254
273
  Joi.object({
255
274
  to: addressSchema.label('ToAddress').required(),
256
275
  messageId: Joi.string().max(996).example('<test123@example.com>').description('Message ID'),
257
- params: Joi.object().label('RenderValues').description('An object of variables for the template renderer'),
276
+ params: Joi.object()
277
+ .label('RenderValues')
278
+ .example({ firstName: 'Nyan', orderId: '4815' })
279
+ .description('An object of variables for the template renderer'),
258
280
  sendAt: Joi.date()
259
281
  .iso()
260
282
  .example('2021-07-08T07:06:34.336Z')
@@ -262,9 +284,8 @@ async function init(args) {
262
284
  }).label('MailMergeListEntry')
263
285
  )
264
286
  .min(1)
265
- .description(
266
- 'Mail merge options. A separate email is generated for each recipient. Using mail merge disables `messageId`, `envelope`, `to`, `cc`, `bcc`, `render` keys for the message root.'
267
- )
287
+ .description('Mail merge options. A separate email is generated for each recipient')
288
+ .meta({ usage: FIELD_USAGE.mailMerge })
268
289
  .label('MailMergeList'),
269
290
 
270
291
  attachments: Joi.array()
@@ -293,9 +314,8 @@ async function init(args) {
293
314
  .max(256)
294
315
  .allow(false, null)
295
316
  .example('AAAAAQAACnAcde')
296
- .description(
297
- 'References an existing attachment by its ID instead of providing new attachment content. If this field is set, the `content` field must not be included. If not set, the `content` field is required.'
298
- )
317
+ .description('References an existing attachment by its ID instead of providing new attachment content')
318
+ .meta({ usage: FIELD_USAGE.attachmentReference })
299
319
  .label('AttachmentReference')
300
320
  }).label('UploadAttachment')
301
321
  )
@@ -318,9 +338,8 @@ async function init(args) {
318
338
  copy: Joi.boolean()
319
339
  .allow(null)
320
340
  .example(null)
321
- .description(
322
- "If set then either copies the message to the Sent Mail folder or not. If not set then uses the account's default setting."
323
- ),
341
+ .description("If set then either copies the message to the Sent Mail folder or not. If not set then uses the account's default setting")
342
+ .meta({ usage: FIELD_USAGE.messageCopy }),
324
343
 
325
344
  sentMailPath: Joi.string()
326
345
  .empty('')
@@ -489,6 +508,8 @@ async function init(args) {
489
508
  });
490
509
 
491
510
  try {
511
+ assertNoNetworkOverride(request);
512
+
492
513
  return await accountObject.queueMessage(request.payload || {}, {
493
514
  source: 'api',
494
515
  idempotencyKey: request.headers['idempotency-key'],
@@ -509,6 +530,7 @@ async function init(args) {
509
530
 
510
531
  plugins: {
511
532
  openapi: {
533
+ 'x-ee-impact': IMPACT.SENDS,
512
534
  'x-ee-behavior': [BEHAVIOR.QUEUED_DELIVERY, BEHAVIOR.SENT_FOLDER_UPLOAD],
513
535
 
514
536
  // Every property of this payload is an optional override, so a snippet
@@ -570,16 +592,16 @@ async function init(args) {
570
592
  to: Joi.array().items(Joi.string().email().required().example('recipient@example.com')).single().label('DraftSmtpEnvelopeTo')
571
593
  })
572
594
  .description(
573
- "An optional object specifying the SMTP envelope used during email transmission. If not provided, the envelope is derived from the draft's message headers. Only used when the message is delivered over SMTP."
595
+ 'An optional object specifying the SMTP envelope used during email transmission. Only used when the message is delivered over SMTP'
574
596
  )
597
+ .meta({ usage: FIELD_USAGE.messageEnvelope })
575
598
  .label('DraftSMTPEnvelope'),
576
599
 
577
600
  copy: Joi.boolean()
578
601
  .allow(null)
579
602
  .example(null)
580
- .description(
581
- "If set then either copies the message to the Sent Mail folder or not. If not set then uses the account's default setting. Only applies to SMTP deliveries - Gmail and MS Graph file sent drafts into the Sent Mail folder themselves."
582
- ),
603
+ .description("If set then either copies the message to the Sent Mail folder or not. If not set then uses the account's default setting")
604
+ .meta({ usage: FIELD_USAGE.messageCopy }),
583
605
 
584
606
  sentMailPath: Joi.string()
585
607
  .empty('')
@@ -9,6 +9,7 @@ const { failAction } = require('../tools');
9
9
  const { handleError, throwNotFound } = require('./route-helpers');
10
10
 
11
11
  const { templateSchemas, accountIdSchema, apiResponses } = require('../schemas');
12
+ const { IMPACT } = require('./operation-impact');
12
13
 
13
14
  // Template owner field shared by all template response schemas
14
15
  const templateAccountIdSchema = accountIdSchema.required().allow(null).description('Account ID. Null for public templates');
@@ -386,6 +387,7 @@ async function init(args) {
386
387
 
387
388
  plugins: {
388
389
  openapi: {
390
+ 'x-ee-impact': IMPACT.DESTRUCTIVE,
389
391
  responses: apiResponses('Returns a deletion marker.', 400, 401, 403, 429, 500)
390
392
  }
391
393
  },
@@ -450,6 +452,7 @@ async function init(args) {
450
452
 
451
453
  plugins: {
452
454
  openapi: {
455
+ 'x-ee-impact': IMPACT.DESTRUCTIVE,
453
456
  responses: apiResponses('Returns the number of templates removed.', 400, 401, 403, 404, 429, 500)
454
457
  }
455
458
  },