emailengine-app 2.81.2 → 2.82.1

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 (226) hide show
  1. package/.ncurc.js +33 -10
  2. package/.release-please-manifest.json +1 -1
  3. package/CHANGELOG.md +71 -0
  4. package/DOCKER_DEPLOYMENT.md +13 -12
  5. package/Dockerfile +2 -0
  6. package/bin/emailengine.js +105 -25
  7. package/config/default.toml +0 -5
  8. package/config/test.toml +0 -5
  9. package/data/google-crawlers.json +1 -1
  10. package/encrypt.js +70 -42
  11. package/getswagger.sh +0 -4
  12. package/lib/account/account-state.js +2 -110
  13. package/lib/account/expected-identity.js +1 -1
  14. package/lib/account-assignment.js +138 -1
  15. package/lib/account.js +289 -869
  16. package/lib/api-reference/index.js +2 -3
  17. package/lib/api-reference/schema-tree.js +53 -3
  18. package/lib/api-routes/account-binding.js +58 -0
  19. package/lib/api-routes/account-routes.js +65 -37
  20. package/lib/api-routes/behavior-notes.js +4 -0
  21. package/lib/api-routes/blocklist-routes.js +2 -2
  22. package/lib/api-routes/bull-board-routes.js +1 -6
  23. package/lib/api-routes/export-routes.js +2 -22
  24. package/lib/api-routes/gateway-routes.js +15 -16
  25. package/lib/api-routes/index.js +1 -13
  26. package/lib/api-routes/mailbox-routes.js +2 -7
  27. package/lib/api-routes/mcp-oauth-routes.js +2 -1
  28. package/lib/api-routes/mcp-routes.js +7 -7
  29. package/lib/api-routes/message-routes.js +50 -238
  30. package/lib/api-routes/mint-bounds.js +110 -0
  31. package/lib/api-routes/oauth2-app-routes.js +23 -32
  32. package/lib/api-routes/operation-impact.js +1 -1
  33. package/lib/api-routes/outbox-routes.js +3 -3
  34. package/lib/api-routes/permission-map.js +1 -7
  35. package/lib/api-routes/route-helpers.js +11 -5
  36. package/lib/api-routes/settings-routes.js +20 -21
  37. package/lib/api-routes/stats-routes.js +1 -1
  38. package/lib/api-routes/submit-routes.js +17 -18
  39. package/lib/api-routes/template-routes.js +4 -9
  40. package/lib/api-routes/token-routes.js +28 -6
  41. package/lib/api-token-scheme.js +71 -0
  42. package/lib/arf-detect.js +33 -6
  43. package/lib/auth-token.js +44 -24
  44. package/lib/autodetect-imap-settings.js +305 -123
  45. package/lib/bounce-detect.js +25 -16
  46. package/lib/calendar-event.js +78 -0
  47. package/lib/consts.js +54 -5
  48. package/lib/create-imap-client.js +24 -0
  49. package/lib/db.js +77 -30
  50. package/lib/delivery-error.js +70 -2
  51. package/lib/egress-fetch.js +54 -3
  52. package/lib/egress-filter.js +11 -0
  53. package/lib/email-client/api-retry.js +147 -0
  54. package/lib/email-client/base-client.js +383 -536
  55. package/lib/email-client/credential-errors.js +21 -5
  56. package/lib/email-client/gmail/gmail-api.js +38 -125
  57. package/lib/email-client/gmail/send-request.js +1 -1
  58. package/lib/email-client/gmail-client.js +77 -51
  59. package/lib/email-client/imap/mailbox.js +158 -324
  60. package/lib/email-client/imap/stale-view.js +109 -0
  61. package/lib/email-client/imap/subconnection.js +46 -9
  62. package/lib/email-client/imap/sync-operations.js +5 -37
  63. package/lib/email-client/imap-client.js +190 -65
  64. package/lib/email-client/message-builder.js +50 -25
  65. package/lib/email-client/notification-handler.js +5 -219
  66. package/lib/email-client/outlook/graph-api.js +147 -126
  67. package/lib/email-client/outlook/send-request.js +10 -4
  68. package/lib/email-client/outlook-client.js +389 -463
  69. package/lib/email-client/smtp-pool-manager.js +3 -2
  70. package/lib/encrypt.js +184 -19
  71. package/lib/enum-descriptions.js +6 -3
  72. package/lib/export.js +141 -41
  73. package/lib/gateway.js +25 -6
  74. package/lib/get-raw-email.js +26 -44
  75. package/lib/get-secret.js +1 -21
  76. package/lib/handlebars-helpers.js +31 -10
  77. package/lib/imap-proxy-auth.js +13 -29
  78. package/lib/imapproxy/imap-core/README.md +1 -0
  79. package/lib/imapproxy/imap-core/lib/handler/imap-parser.js +12 -0
  80. package/lib/imapproxy/imap-core/lib/imap-command.js +74 -10
  81. package/lib/imapproxy/imap-core/lib/imap-connection.js +9 -1
  82. package/lib/imapproxy/imap-core/lib/imap-server.js +112 -26
  83. package/lib/imapproxy/imap-core/lib/imap-stream.js +41 -1
  84. package/lib/imapproxy/imap-core/lib/imap-tools.js +10 -2
  85. package/lib/imapproxy/imap-core/lib/indexer/indexer.js +4 -2
  86. package/lib/imapproxy/imap-server.js +17 -177
  87. package/lib/imapproxy/proxy-handoff.js +235 -0
  88. package/lib/imapproxy/response-error.js +33 -0
  89. package/lib/imapproxy/upstream-client.js +2 -2
  90. package/lib/license-beacon.js +3 -9
  91. package/lib/llm-pre-process.js +182 -43
  92. package/lib/logger.js +1 -1
  93. package/lib/lua/ee-export-queue-add.lua +39 -0
  94. package/lib/lua/ee-get-idempotency.lua +15 -3
  95. package/lib/lua/ee-release-attempts.lua +23 -0
  96. package/lib/lua/ee-reserve-attempts.lua +42 -0
  97. package/lib/lua/h-set-bigger.lua +12 -2
  98. package/lib/lua/s-list-accounts.lua +6 -3
  99. package/lib/mcp/index.js +1 -2
  100. package/lib/mcp/listen.js +221 -18
  101. package/lib/mcp/oauth.js +44 -5
  102. package/lib/mcp/resources.js +8 -2
  103. package/lib/mcp/tools.js +108 -36
  104. package/lib/message-port-stream.js +64 -6
  105. package/lib/oauth/external-account-signer.js +16 -13
  106. package/lib/oauth/gmail.js +64 -32
  107. package/lib/oauth/mail-ru.js +24 -17
  108. package/lib/oauth/outlook.js +53 -40
  109. package/lib/oauth/pubsub/google.js +38 -2
  110. package/lib/oauth/scope-checker.js +39 -8
  111. package/lib/oauth/scope-list.js +55 -0
  112. package/lib/oauth/token-fetch.js +47 -0
  113. package/lib/oauth/verify-app.js +2 -2
  114. package/lib/oauth2-apps.js +154 -90
  115. package/lib/openapi/build-document.js +1 -1
  116. package/lib/openapi/joi-schema.js +78 -9
  117. package/lib/outbox.js +2 -7
  118. package/lib/parse-message.js +21 -0
  119. package/lib/payload-examples-webhooks.json +4 -7
  120. package/lib/pbkdf2-phc.js +101 -0
  121. package/lib/privileged-settings.js +0 -14
  122. package/lib/queue-retention.js +4 -2
  123. package/lib/rate-limit.js +54 -15
  124. package/lib/read-env-value.js +33 -2
  125. package/lib/redis-scan-delete.js +56 -29
  126. package/lib/redis-url.js +3 -1
  127. package/lib/respawn-backoff.js +5 -4
  128. package/lib/response-stream.js +25 -4
  129. package/lib/rewrite-text-nodes.js +27 -40
  130. package/lib/routes-ui.js +0 -5
  131. package/lib/schemas.js +180 -253
  132. package/lib/sentry.js +21 -5
  133. package/lib/settings.js +58 -59
  134. package/lib/smtp-auth.js +6 -2
  135. package/lib/smtp-message-processor.js +28 -7
  136. package/lib/sso.js +7 -3
  137. package/lib/stream-encrypt.js +14 -13
  138. package/lib/swagger-options.js +3 -1
  139. package/lib/tls/provision.js +69 -3
  140. package/lib/tls/store.js +14 -1
  141. package/lib/token-audit-log.js +3 -2
  142. package/lib/tools.js +114 -53
  143. package/lib/totp.js +16 -1
  144. package/lib/ui-routes/account-routes.js +67 -70
  145. package/lib/ui-routes/admin-config-routes.js +111 -134
  146. package/lib/ui-routes/admin-entities-routes.js +101 -191
  147. package/lib/ui-routes/ai-options.js +104 -0
  148. package/lib/ui-routes/auth-routes.js +98 -18
  149. package/lib/ui-routes/export-routes.js +3 -23
  150. package/lib/ui-routes/internals-routes.js +12 -9
  151. package/lib/ui-routes/network-config-routes.js +8 -18
  152. package/lib/ui-routes/oauth-config-routes.js +83 -228
  153. package/lib/ui-routes/route-helpers.js +63 -67
  154. package/lib/ui-routes/special-use-paths.js +33 -0
  155. package/lib/ui-routes/unsubscribe-routes.js +2 -2
  156. package/lib/utils/decode-headers.js +32 -5
  157. package/lib/utils/header-map.js +62 -1
  158. package/lib/utils/network.js +11 -17
  159. package/lib/web-safe-html.js +77 -4
  160. package/lib/webhook-request.js +9 -1
  161. package/lib/webhook-routing.js +27 -1
  162. package/lib/webhooks.js +120 -43
  163. package/lib/worker-rpc-error.js +43 -2
  164. package/list-generate.js +13 -2
  165. package/package.json +38 -46
  166. package/sbom.json +1 -1
  167. package/scripts/refresh-test-tokens.js +42 -14
  168. package/server.js +338 -292
  169. package/setup-production.sh +16 -7
  170. package/static/css/flyonui.css +1 -1
  171. package/static/css/src/app.tailwind.css +7 -8
  172. package/static/js/ee-client.js +145 -70
  173. package/static/js/ui.js +350 -154
  174. package/static/licenses.html +349 -1740
  175. package/translations/messages.pot +129 -111
  176. package/views/account-workspace-error.hbs +30 -0
  177. package/views/accounts/account.hbs +9 -4
  178. package/views/accounts/browse.hbs +10 -4
  179. package/views/accounts/edit.hbs +11 -2
  180. package/views/config/ai.hbs +49 -41
  181. package/views/config/oauth/app.hbs +2 -1
  182. package/views/dashboard.hbs +18 -16
  183. package/views/internals/index.hbs +1 -1
  184. package/views/layout/app.hbs +0 -22
  185. package/views/layout/login.hbs +2 -1
  186. package/views/partials/filter_editor_js.hbs +4 -3
  187. package/views/partials/gmail_api_scopes.hbs +16 -0
  188. package/views/partials/oauth_form.hbs +67 -94
  189. package/views/partials/oauth_pubsub_app_select.hbs +43 -0
  190. package/views/partials/scope_info.hbs +14 -23
  191. package/views/partials/side_menu.hbs +0 -4
  192. package/views/partials/ui/account-picker.hbs +6 -32
  193. package/views/partials/ui/model-picker.hbs +31 -0
  194. package/views/partials/ui/pagination.hbs +6 -1
  195. package/views/partials/ui/picker.hbs +47 -0
  196. package/views/unsubscribe.hbs +1 -1
  197. package/workers/api.js +82 -47
  198. package/workers/export.js +55 -60
  199. package/workers/imap.js +132 -49
  200. package/workers/submit.js +5 -6
  201. package/workers/webhooks.js +46 -27
  202. package/.githooks/pre-commit +0 -80
  203. package/.github/CODE_OF_CONDUCT.md +0 -76
  204. package/.github/contributing.md +0 -17
  205. package/.github/dependabot.yml +0 -22
  206. package/.github/docker-smoke-test.sh +0 -61
  207. package/.github/workflows/deploy.yml +0 -215
  208. package/.github/workflows/e2e.yml +0 -55
  209. package/.github/workflows/release.yaml +0 -217
  210. package/.github/workflows/test.yml +0 -307
  211. package/lib/api-routes/chat-routes.js +0 -535
  212. package/lib/document-store.js +0 -75
  213. package/lib/es.js +0 -757
  214. package/lib/generate-text-preview.js +0 -61
  215. package/lib/imapproxy/imap-core/memory-notifier.js +0 -129
  216. package/lib/pre-process.js +0 -196
  217. package/lib/threads.js +0 -155
  218. package/lib/ui-routes/document-store-routes.js +0 -806
  219. package/playwright.config.js +0 -47
  220. package/views/config/document-store/chat.hbs +0 -286
  221. package/views/config/document-store/index.hbs +0 -146
  222. package/views/config/document-store/mappings/index.hbs +0 -108
  223. package/views/config/document-store/mappings/new.hbs +0 -68
  224. package/views/config/document-store/pre-processing/index.hbs +0 -103
  225. package/views/partials/document_store_header.hbs +0 -30
  226. package/workers/documents.js +0 -1128
@@ -1,7 +1,7 @@
1
1
  {{> ui/page-header title="AI Processing" icon="icon-[tabler--robot]" class="mb-1"}}
2
2
 
3
- <p class="mb-6">Analyze new Inbox emails with AI and include the results in <code>messageNew</code> webhooks.
4
- EmailEngine sends email content to the AI provider configured below.
3
+ <p class="mb-6">Analyze new Inbox emails with AI and include the model's answer as <code>summary</code> in
4
+ <code>messageNew</code> webhooks. EmailEngine sends email content to the AI provider configured below.
5
5
  </p>
6
6
 
7
7
  {{> ui/env-managed-alert}}
@@ -39,8 +39,8 @@
39
39
  before enabling processing.
40
40
  {{/ui/tooltip-rich}}
41
41
  {{/ui/checkbox}}
42
- <span class="helper-text">Process new emails with AI and include the results in
43
- <code>messageNew</code> webhooks.</span>
42
+ <span class="helper-text">Process new emails with AI and include the results as
43
+ <code>summary</code> in <code>messageNew</code> webhooks.</span>
44
44
  </div>
45
45
 
46
46
  <div class="text-end space-y-1">
@@ -68,23 +68,14 @@
68
68
  {{> ui/setting-ref name="openAiModel"}}
69
69
 
70
70
  <div class="flex items-center gap-2">
71
- <label class="label-text" for="settingsServiceOpenAiModel">AI Model</label>
71
+ <label class="label-text" for="openAiModel-search">AI Model</label>
72
72
 
73
73
  {{> ui/btn label="Refresh models" style="text" size="sm" id="reload-models-btn"
74
74
  icon="icon-[tabler--refresh] reload-icon"}}
75
75
  </div>
76
76
 
77
- <select id="settingsServiceOpenAiModel" class="select max-w-md{{#if errors.openAiModel}} is-invalid{{/if}}"
78
- name="openAiModel">
79
- {{#each openAiModels}}
80
- <option value="{{id}}" {{#if selected}}selected{{/if}}>{{name}}</option>
81
- {{/each}}
82
- </select>
83
- {{#if errors.openAiModel}}
84
- <span class="helper-text text-error">{{errors.openAiModel}}</span>
85
- {{/if}}
86
- <span class="helper-text">Choose the AI model for processing. Ensure your API key has access to the
87
- selected model.</span>
77
+ {{> ui/model-picker id="openAiModel" models=openAiModels value=values.openAiModel error=errors.openAiModel
78
+ hint="Type to search. Refresh models lists what your API key can use; the recommended entries suit reading mail, and Default follows the built-in model across upgrades."}}
88
79
  </div>
89
80
 
90
81
  <div>
@@ -215,7 +206,7 @@
215
206
  <input type="hidden" class="{{#if errors.openAiPromptElement}}is-invalid{{/if}}"
216
207
  id="openAiPromptElement" name="openAiPrompt" value="{{values.openAiPrompt}}">
217
208
 
218
- {{#> ui/code-editor id="editor-prompt" title="System prompt"}}
209
+ {{#> ui/code-editor id="editor-prompt" title="AI instructions"}}
219
210
  <div class="editor-embed-content editor-embed-content-right">
220
211
  <a href="#" id="prompt-try-btn">Test with email file</a>
221
212
  </div>
@@ -226,8 +217,10 @@
226
217
  <span class="helper-text text-error">{{errors.openAiPrompt}}</span>
227
218
  {{/if}}
228
219
 
229
- <span class="helper-text">Instructions for the AI. Must specify which JSON properties to return in the
230
- response.</span>
220
+ <span class="helper-text">Instructions for the AI, sent as the system message ahead of the email. They must
221
+ say which JSON properties to return; the webhook carries the model's answer as it came. The built-in
222
+ instructions ask for a summary, the sentiment, whether a reply is expected, a risk score, and the
223
+ events and actions the email mentions.</span>
231
224
  </div>
232
225
 
233
226
  <div>
@@ -236,7 +229,8 @@
236
229
  <input type="number" class="input text-list{{#if errors.openAiTemperature}} is-invalid{{/if}}"
237
230
  id="settingsOpenAiTemperature" step="0.001" min="0" max="2" name="openAiTemperature"
238
231
  value="{{values.openAiTemperature}}" />
239
- <span class="helper-text">Controls randomness (0-2). Lower = more focused, higher = more creative. <a
232
+ <span class="helper-text">Controls randomness (0-2). Lower = more focused, higher = more creative. Not
233
+ sent to a reasoning model while it reasons. <a
240
234
  href="https://platform.openai.com/docs/api-reference/chat/create#temperature" target="_blank"
241
235
  rel="noopener noreferrer" referrerpolicy="no-referrer" class="link link-animated">Learn
242
236
  more</a></span>
@@ -249,22 +243,43 @@
249
243
  <input type="number" class="input text-list{{#if errors.openAiTopP}} is-invalid{{/if}}"
250
244
  id="settingsOpenAiTopP" step="0.001" min="0" max="1" name="openAiTopP"
251
245
  value="{{values.openAiTopP}}" />
252
- <span class="helper-text">Alternative to temperature (0-1). Controls diversity of word choices. <a
246
+ <span class="helper-text">Alternative to temperature (0-1). Controls diversity of word choices. Not sent
247
+ to a reasoning model while it reasons. <a
253
248
  href="https://platform.openai.com/docs/api-reference/chat/create#top_p" target="_blank"
254
249
  rel="noopener noreferrer" referrerpolicy="no-referrer" class="link link-animated">Learn
255
250
  more</a></span>
256
251
  {{/ui/form-field}}
257
252
  </div>
258
253
 
254
+ <div>
255
+ {{> ui/setting-ref name="openAiReasoningEffort"}}
256
+
257
+ <label class="label-text" for="settingsOpenAiReasoningEffort">Reasoning effort</label>
258
+
259
+ <select id="settingsOpenAiReasoningEffort"
260
+ class="select max-w-md{{#if errors.openAiReasoningEffort}} is-invalid{{/if}}"
261
+ name="openAiReasoningEffort">
262
+ {{#each reasoningEffortOptions}}
263
+ <option value="{{value}}" {{#if selected}}selected{{/if}}>{{label}}</option>
264
+ {{/each}}
265
+ </select>
266
+ {{#if errors.openAiReasoningEffort}}
267
+ <span class="helper-text text-error">{{errors.openAiReasoningEffort}}</span>
268
+ {{/if}}
269
+ <span class="helper-text">How much a reasoning model, GPT-5 and later, thinks before answering. Default
270
+ sends "low" to such a model and nothing to any other. A value the model does not support is
271
+ dropped.</span>
272
+ </div>
273
+
259
274
  <div>
260
275
  {{> ui/setting-ref name="openAiMaxTokens"}}
261
276
  {{#> ui/form-field id="settingsOpenAiMaxTokens" label="Input token limit" error=errors.openAiMaxTokens}}
262
277
  <input type="number" class="input text-list{{#if errors.openAiMaxTokens}} is-invalid{{/if}}"
263
278
  id="settingsOpenAiMaxTokens" step="1" min="0" name="openAiMaxTokens"
264
279
  value="{{values.openAiMaxTokens}}" />
265
- <span class="helper-text">Maximum tokens in the input prompt, including your instructions, the system prompt, the JSON schema,
266
- and email data. EmailEngine shortens the email content to fit this limit. Leave blank for
267
- EmailEngine's model-based default.</span>
280
+ <span class="helper-text">Maximum tokens in the input prompt: the instructions and the email together.
281
+ EmailEngine shortens the email text to fit this limit. Leave blank for the default of
282
+ {{aiDefaults.maxTokens}}.</span>
268
283
  {{/ui/form-field}}
269
284
  </div>
270
285
 
@@ -367,11 +382,13 @@ defaultTestPayload='{"account":"test","path":"INBOX","subject":"test email"}'}}
367
382
  let payload = {
368
383
  emailFile,
369
384
  openAiPrompt: editorPrompt.getValue(),
370
- openAiModel: document.getElementById('settingsServiceOpenAiModel').value,
385
+ openAiModel: document.getElementById('openAiModel').value,
371
386
  openAiAPIUrl: document.getElementById('openAiAPIUrl').value,
372
387
  openAiAPIKey: document.getElementById('openAiAPIKey').value,
373
388
  openAiTemperature: document.getElementById('settingsOpenAiTemperature').value,
374
- openAiTopP: document.getElementById('settingsOpenAiTopP').value
389
+ openAiTopP: document.getElementById('settingsOpenAiTopP').value,
390
+ openAiReasoningEffort: document.getElementById('settingsOpenAiReasoningEffort').value,
391
+ openAiMaxTokens: document.getElementById('settingsOpenAiMaxTokens').value
375
392
  };
376
393
 
377
394
  let data;
@@ -405,21 +422,11 @@ defaultTestPayload='{"account":"test","path":"INBOX","subject":"test email"}'}}
405
422
  runFileTest();
406
423
  });
407
424
 
408
- function redrawModelList(models) {
409
- let selectElm = document.getElementById('settingsServiceOpenAiModel');
410
- let selected = selectElm.value;
411
-
412
- selectElm.innerHTML = '';
425
+ const modelInput = document.getElementById('openAiModel');
413
426
 
414
- for (let model of models) {
415
- let elm = document.createElement('option');
416
- elm.setAttribute('value', model.id);
417
- elm.textContent = model.name;
418
- if (model.id === selected) {
419
- elm.selected = true
420
- }
421
- selectElm.appendChild(elm);
422
- }
427
+ // the server answers with the list in the shape the page first got it
428
+ function redrawModelList(models) {
429
+ uiModelPickerSetModels(modelInput, models);
423
430
  }
424
431
 
425
432
  let reloadBtn = document.getElementById('reload-models-btn');
@@ -427,7 +434,8 @@ defaultTestPayload='{"account":"test","path":"INBOX","subject":"test email"}'}}
427
434
  const requestReload = async () => {
428
435
  const data = await uiPostJson('/admin/config/ai/reload-models', {
429
436
  openAiAPIUrl: document.getElementById('openAiAPIUrl').value,
430
- openAiAPIKey: document.getElementById('openAiAPIKey').value
437
+ openAiAPIKey: document.getElementById('openAiAPIKey').value,
438
+ openAiModel: modelInput.value
431
439
  });
432
440
 
433
441
  return data;
@@ -364,9 +364,10 @@ fieldName="app" fieldValue=app.id submitLabel="Delete app" submitIcon="icon-[tab
364
364
  </script>
365
365
  {{/if}}
366
366
 
367
+ <input type="hidden" id="verify-app-id" value="{{app.id}}">
367
368
  <script data-cfasync="false" nonce="{{cspNonce}}">
368
369
  document.addEventListener('DOMContentLoaded', () => {
369
- const appId = "{{app.id}}";
370
+ const appId = document.getElementById('verify-app-id').value;
370
371
  const stepsElm = document.getElementById('verify-steps');
371
372
  const pendingElm = document.getElementById('verify-pending');
372
373
  const errorElm = document.getElementById('verify-error');
@@ -54,16 +54,22 @@
54
54
  {{/ui/stat-card}}
55
55
  {{/each}}
56
56
 
57
- {{#if documentStoreUnavailable}}
58
- {{#> ui/stat-card variant="error" title="Document Store unavailable" icon="icon-[tabler--database]" class="mt-6"}}
59
- <p class="mb-0">The Document Store is enabled in the EmailEngine settings, but the feature is not
60
- available because EmailEngine was not started with the Document Store enabled. The deprecated
61
- Document Store only runs when started with the <code>--documentStore.enabled</code> command line
62
- flag or the <code>EENGINE_DOCUMENT_STORE_ENABLED=true</code> environment variable. Until then the
63
- document store worker is not running and all Document Store API and configuration endpoints
64
- return 404. Either restart EmailEngine with the flag, or disable the <code>documentStoreEnabled</code>
65
- setting to clear this warning.</p>
66
- {{/ui/stat-card}}
57
+ {{!-- Shown while the removed Document Store is still switched on in the stored settings.
58
+ The close button clears that setting through /admin/config/clear-error. --}}
59
+ {{#if documentStoreRemoved}}
60
+ {{#> ui/clear-alert alert="document-store" class="mt-6"}}
61
+ <h4 class="text-lg font-bold mb-2">The Document Store is no longer available</h4>
62
+ <p class="mb-2">This instance still has the <strong>Document Store</strong> enabled in its settings, but the
63
+ feature has been removed from EmailEngine. Emails are no longer indexed into Elasticsearch, and the
64
+ endpoints that depended on it (chat with emails, unified search, the <code>documentStore</code>
65
+ request options) are gone.</p>
66
+ <p class="mb-2">If you still need the Document Store, downgrade this instance to
67
+ <strong>v{{lastDocumentStoreVersion}}</strong>, the last release that includes it. Be aware that a
68
+ frozen version does <strong>not receive security updates</strong>, so continuing to run it is entirely
69
+ at your own risk.</p>
70
+ <p class="mb-0">Otherwise close this notice to clear the setting and drop the indexing jobs still queued in
71
+ Redis. The rest of the stored Document Store configuration is left untouched.</p>
72
+ {{/ui/clear-alert}}
67
73
  {{/if}}
68
74
 
69
75
  {{#unless hasAccounts}}
@@ -149,18 +155,14 @@
149
155
 
150
156
  {{> ui/section-title label="System" class="mt-8 mb-3"}}
151
157
 
152
- {{!-- auto-fit, so the tiles fill the row whether or not the Document Store adds a third
153
- queue - a fixed four-column track left a quarter-width hole at the end without it --}}
158
+ {{!-- auto-fit, so the tiles fill the row however many there are - a fixed four-column track
159
+ left a quarter-width hole at the end --}}
154
160
  <div class="grid grid-cols-2 gap-4 xl:grid-cols-[repeat(auto-fit,minmax(15rem,1fr))]">
155
161
 
156
162
  {{> queueCard queue=stats.queues.notify href="/admin/bull-board/queue/Webhooks%20Queue%20-%20notify" label="Webhooks queue" tooltip="This queue processes webhook notifications" delayedTooltip="Delayed queue entries"}}
157
163
 
158
164
  {{> queueCard queue=stats.queues.submit href="/admin/bull-board/queue/Submission%20Queue%20-%20submit" label="Submission queue" tooltip="This queue processes outgoing emails" delayedTooltip="Delayed queue entries, including emails scheduled to be sent later"}}
159
165
 
160
- {{#if showDocumentStore}}
161
- {{> queueCard queue=stats.queues.documents href="/admin/bull-board/queue/Document%20Queue%20-%20documents" label="Documents queue" tooltip="This queue indexes mailbox changes to Elasticsearch" delayedTooltip="Delayed queue entries"}}
162
- {{/if}}
163
-
164
166
  {{#> ui/stat-card variant=(eeColor redisPing.color) icon=redisPing.icon}}
165
167
  <div class="text-sm font-medium text-base-content/60 mb-1">
166
168
  {{#if redisPing.comment}}
@@ -140,7 +140,7 @@
140
140
  <p class="mb-4">EmailEngine spreads its work across worker threads - account sync, the API and web server, webhook
141
141
  delivery, message submission, and exports. Their counts are set at startup with environment variables such as
142
142
  <code>EENGINE_WORKERS</code> (account sync), <code>EENGINE_WORKERS_API</code>, <code>EENGINE_WORKERS_WEBHOOKS</code>,
143
- and <code>EENGINE_WORKERS_SUBMIT</code>.</p>
143
+ <code>EENGINE_WORKERS_SUBMIT</code> and <code>EENGINE_WORKERS_EXPORT</code>.</p>
144
144
  <p class="mb-4">Most worker types can be scaled to several threads with those variables. The HTTP and API server is
145
145
  the exception: running more than one API worker requires <code>SO_REUSEPORT</code>, which is available only on
146
146
  Linux with Node.js 23.1 or newer. On macOS, Windows, or older Node.js versions EmailEngine falls back to a
@@ -291,28 +291,6 @@
291
291
  {{/unless}}
292
292
  {{/unless}}
293
293
 
294
- {{!-- Deprecated Document Store removal notice. Shown (and not dismissible) on every admin
295
- page whenever the Document Store is genuinely active (feature gate on + setting on).
296
- Rendered as a SOLID error alert (not a stat-card) so it stands out from the page's
297
- white cards. Removal date is 2026-10-01. --}}
298
- {{#if showDocumentStore}}
299
- <div class="alert alert-error border-2 shadow-lg mb-6 flex items-start gap-4" role="alert">
300
- <span class="icon-[tabler--alert-triangle] size-8 shrink-0 mt-0.5"></span>
301
- <div class="grow">
302
- <h4 class="text-lg font-bold mb-2">Document Store is being removed</h4>
303
- <p class="mb-2">This instance still has the deprecated <strong>Document Store</strong>
304
- enabled. Starting <strong>October 1, 2026</strong>, the Document Store will be removed
305
- from EmailEngine releases. After that, syncing emails to ElasticSearch and the related
306
- endpoints (chat with email, unified search) will no longer be available.</p>
307
- <p class="mb-3">If you want to keep using the Document Store, <strong>do not upgrade</strong>
308
- this EmailEngine instance beyond the last release that still includes it. Be aware that
309
- such a frozen version will <strong>not receive security updates</strong>, so continuing
310
- to run it is entirely at your own risk.</p>
311
- {{> ui/btn href="/admin/config/document-store" variant="neutral" size="sm" icon="icon-[tabler--arrow-right]" label="Review Document Store settings"}}
312
- </div>
313
- </div>
314
- {{/if}}
315
-
316
294
  {{{content}}}
317
295
 
318
296
  </div>
@@ -23,7 +23,8 @@
23
23
  login form never emits this and no user input reaches the string. Why that page navigates
24
24
  itself instead of the server answering a redirect is the whole story in the view. --}}
25
25
  {{#if ssoRedirectUrl}}
26
- <script data-cfasync="false" nonce="{{cspNonce}}">window.location.replace('{{ssoRedirectUrl}}');</script>
26
+ <meta name="ee-sso-redirect" content="{{ssoRedirectUrl}}">
27
+ <script data-cfasync="false" nonce="{{cspNonce}}">window.location.replace(document.querySelector('meta[name="ee-sso-redirect"]').content);</script>
27
28
  {{/if}}
28
29
 
29
30
  {{> head_assets}}
@@ -1,8 +1,8 @@
1
1
  {{!--
2
2
  Shared filter/map editor test machinery: the ACE editors, the evaluation web
3
3
  worker, live filter-result painting and the "set test payload" modal. Used by
4
- the webhook routing pages (via webhooks_editor_functions), the AI pre-filter
5
- page and the Document Store pre-processing page.
4
+ the webhook routing pages (via webhooks_editor_functions) and the AI pre-filter
5
+ page.
6
6
  Hash params (all optional):
7
7
  hasMap - truthy to include the output-mapping editor/preview pair
8
8
  and the map evaluation chain
@@ -30,6 +30,7 @@
30
30
  <input type="hidden" id="examplePayloadsJson" value="{{examplePayloadsJson}}">
31
31
  <input type="hidden" id="scriptEnvJson" value="{{scriptEnvJson}}">
32
32
  <input type="hidden" id="defaultTestPayloadJson" value="{{defaultTestPayload}}">
33
+ <input type="hidden" id="filterEditorFormId" value="{{#if formId}}{{formId}}{{else}}edit-form{{/if}}">
33
34
 
34
35
  {{#> ui/modal id="setPayloadModal" title=(when modalTitle modalTitle "Set test payload") dialogClass="max-w-3xl"}}
35
36
  <div class="modal-body">
@@ -229,7 +230,7 @@ the *Set test payload* button to change the filter payload.`);
229
230
  editorMapPreview.clearSelection(1);
230
231
  {{/if}}
231
232
 
232
- document.getElementById('{{#if formId}}{{formId}}{{else}}edit-form{{/if}}').addEventListener('submit', () => {
233
+ document.getElementById(document.getElementById('filterEditorFormId').value).addEventListener('submit', () => {
233
234
  document.getElementById('fn-content-element').value = JSON.stringify(editorFn.getValue());
234
235
  {{#if hasMap}}
235
236
  document.getElementById('map-content-element').value = JSON.stringify(editorMap.getValue());
@@ -0,0 +1,16 @@
1
+ {{!-- The Gmail API scopes an app in `baseScopes: api` mode requests, as list items. Shared by the
2
+ interactive `gmail` block and the `gmailService` one: what an app asks Google for follows from its own
3
+ scope selection, not from whether a person or a service account presents it. A service-account app
4
+ listing gmail.modify here while it had deliberately skipped it is the bug this partial exists to stop
5
+ coming back. --}}
6
+
7
+ {{#unless disabledScopes.Gmail_Modify}}
8
+ <li><code>"https://www.googleapis.com/auth/gmail.modify"</code></li>
9
+ {{else}}
10
+ {{#if isSendOnlyGmail}}
11
+ <li><code>"https://www.googleapis.com/auth/gmail.send"</code></li>
12
+ {{else}}
13
+ <li><code>"https://www.googleapis.com/auth/gmail.readonly"</code></li>
14
+ <li><code>"https://www.googleapis.com/auth/gmail.labels"</code></li>
15
+ {{/if}}
16
+ {{/unless}}
@@ -81,9 +81,9 @@ Read about setting up {{providerData.comment}} from <a href="{{providerData.tuto
81
81
  {{#if activeGmail}}
82
82
  <div>
83
83
  {{> ui/checkbox id="googleWorkspaceAccounts" name="googleWorkspaceAccounts"
84
- label="Show only Google Workspace accounts on the OAuth2 login page"
84
+ label="Accept only Google Workspace accounts"
85
85
  checked=values.googleWorkspaceAccounts error=errors.googleWorkspaceAccounts
86
- hint="When enabled, only Google Workspace accounts will be available on the Gmail OAuth2 login screen."}}
86
+ hint="Shows only Google Workspace accounts on the Gmail sign-in screen, and refuses the setup if a personal account signs in anyway."}}
87
87
  </div>
88
88
  {{/if}}
89
89
 
@@ -441,6 +441,20 @@ Read about setting up {{providerData.comment}} from <a href="{{providerData.tuto
441
441
  <td>Regular email protocols</td>
442
442
  <td><code>"https://mail.google.com/"</code> consent screen scope</td>
443
443
 
444
+ </tr>
445
+ <tr>
446
+ <td>
447
+ <div class="flex items-center gap-2">
448
+ <input class="radio radio-sm base-scopes-radio" type="radio" name="baseScopes"
449
+ id="baseScopesAPI" value="api" {{#if baseScopesApi}}checked{{/if}}>
450
+ <label class="label-text p-0" for="baseScopesAPI">
451
+ Gmail API {{> ui/badge label="beta" variant="neutral"}}
452
+ </label>
453
+ </div>
454
+ </td>
455
+ <td>Gmail HTTP API, through domain-wide delegation</td>
456
+ <td><code>"/auth/gmail.modify"</code> delegated scope</td>
457
+
444
458
  </tr>
445
459
  <tr>
446
460
  <td>
@@ -469,6 +483,17 @@ Read about setting up {{providerData.comment}} from <a href="{{providerData.tuto
469
483
  </tr>
470
484
  {{/if}}
471
485
 
486
+ {{#if baseScopesApi}}
487
+ <tr>
488
+ <td>
489
+ <strong>Gmail API</strong> {{> ui/badge label="beta" variant="neutral"}}
490
+ </td>
491
+ <td>Gmail HTTP API, through domain-wide delegation</td>
492
+ <td><code>"/auth/gmail.modify"</code> delegated scope</td>
493
+
494
+ </tr>
495
+ {{/if}}
496
+
472
497
  {{#if baseScopesPubsub}}
473
498
  <tr>
474
499
  <td>
@@ -486,8 +511,10 @@ Read about setting up {{providerData.comment}} from <a href="{{providerData.tuto
486
511
  </table>
487
512
  </div>
488
513
 
489
- <div id="select-pubsub-app"
490
- class="card-footer border-base-content/10 border-t px-6 py-4{{#unless baseScopesPubsub}} hidden{{/unless}}">
514
+ {{> oauth_pubsub_app_select}}
515
+
516
+ <div class="card-footer border-base-content/10 border-t px-6 py-4{{#unless baseScopesPubsub}} hidden{{/unless}}"
517
+ data-base-scopes="pubsub">
491
518
 
492
519
  {{#if actionCreate}}
493
520
 
@@ -624,40 +651,7 @@ Read about setting up {{providerData.comment}} from <a href="{{providerData.tuto
624
651
  </table>
625
652
  </div>
626
653
 
627
- <div id="select-pubsub-app"
628
- class="card-footer border-base-content/10 border-t px-6 py-4{{#unless baseScopesApi}} hidden{{/unless}}">
629
-
630
- <p class="mb-2">
631
- For faster webhook notifications, select a Gmail service account with the Pub/Sub Admin role.
632
- EmailEngine uses it to set up Google Cloud Pub/Sub for accounts managed by this app.
633
- </p>
634
-
635
- <p class="mb-2">
636
- <strong>Note:</strong> This is optional but recommended. With a Pub/Sub service account, EmailEngine
637
- receives changes in near real time. Without one, it falls back to polling each account about every 10
638
- minutes, so webhooks for new, updated, or deleted emails (and bounce detection) still fire, just with up
639
- to a 10-minute delay. Send-only accounts don't require this.
640
- </p>
641
-
642
- <label class="label-text" for="pubSubApp">Select service account to manage webhooks (optional). The service
643
- account must be for the same Google Cloud Project.</label>
644
- <select class="select w-full{{#if errors.pubSubApp}} is-invalid{{/if}}" id="pubSubApp"
645
- name="pubSubApp" {{#unless baseScopesApi}}disabled{{/unless}}>
646
-
647
- <option value="">Select the service account for your project</option>
648
-
649
- {{#each pubSubApps}}
650
- <option value="{{id}}" data-project="{{googleProjectId}}" {{#if selected}}selected{{/if}} {{#unless
651
- baseScopesApi}}disabled{{/unless}}>{{name}}{{#if
652
- description}} -
653
- {{description}}{{/if}} [{{googleProjectId}}]</option>
654
- {{/each}}
655
-
656
- </select>
657
- {{#if errors.pubSubApp}}
658
- <span class="helper-text text-error">{{errors.pubSubApp}}</span>
659
- {{/if}}
660
- </div>
654
+ {{> oauth_pubsub_app_select}}
661
655
 
662
656
  </div>
663
657
  {{/if}}
@@ -744,8 +738,8 @@ Read about setting up {{providerData.comment}} from <a href="{{providerData.tuto
744
738
  </table>
745
739
  </div>
746
740
 
747
- <div id="select-pubsub-app"
748
- class="card-footer border-base-content/10 border-t px-6 py-4{{#unless baseScopesApi}} hidden{{/unless}}">
741
+ <div class="card-footer border-base-content/10 border-t px-6 py-4{{#unless baseScopesApi}} hidden{{/unless}}"
742
+ data-base-scopes="api">
749
743
 
750
744
  <p class="mb-2">Microsoft Graph delivers change notifications to EmailEngine at these two endpoints:</p>
751
745
 
@@ -815,7 +809,9 @@ Read about setting up {{providerData.comment}} from <a href="{{providerData.tuto
815
809
 
816
810
  {{/if}}
817
811
 
818
- {{#if activeGmail}}
812
+ {{!-- Guarded on providerData.gmailApi, not on one provider: a service account in Gmail API mode takes
813
+ the same delegated scopes an interactive app takes, so the presets apply to it too. --}}
814
+ {{#if providerData.gmailApi}}
819
815
  <div class="card bg-base-100 shadow-md mb-6{{#unless baseScopesApi}} hidden{{/unless}}" id="account-type-card-gmail">
820
816
  <div class="card-header">
821
817
  <h6 class="card-title text-primary">Scope presets</h6>
@@ -911,7 +907,7 @@ open=values.extraScopes}}
911
907
  <p class="mb-4">Request additional OAuth2 scopes, for example when your application uses the provider access tokens
912
908
  for services beyond email.</p>
913
909
 
914
- {{#if activeGmail}}
910
+ {{#if providerData.gmailApi}}
915
911
  <div class="alert alert-soft alert-info mb-4 block">
916
912
  <p>When adding new scopes, ensure that related APIs are
917
913
  enabled for your OAuth2 app (look for <em>Enabled APIs & services</em> in <a
@@ -921,15 +917,6 @@ open=values.extraScopes}}
921
917
  </div>
922
918
  {{/if}}
923
919
 
924
- {{#if activeGmailService}}
925
- <div class="alert alert-soft alert-info mb-4"><span>When adding new scopes, ensure that related APIs are
926
- enabled for your OAuth2 app (look for <em>Enabled APIs & services</em> in <a
927
- href="https://console.cloud.google.com/apis/dashboard" target="_blank" rel="noopener noreferrer"
928
- referrerpolicy="no-referrer" class="link link-animated">Google Cloud Console</a>)
929
- before registering accounts with these permissions. Otherwise, token generation will fail.</span>
930
- </div>
931
- {{/if}}
932
-
933
920
  {{#if activeOutlook}}
934
921
  <div class="alert alert-soft alert-info mb-4"><span>
935
922
 
@@ -986,57 +973,43 @@ open=values.skipScopes}}
986
973
  const pubSubAppElm = document.getElementById('pubSubApp');
987
974
 
988
975
  /**
989
- * Checks and updates the visibility of scope-related UI elements based on selected base scopes radio button.
990
- * Handles both API and Pub/Sub scope selections, showing/hiding relevant configuration sections.
976
+ * Shows the configuration sections that belong to the selected base scope.
977
+ *
978
+ * Each toggled section declares the value that reveals it with `data-base-scopes`, rather than
979
+ * being looked up by element id: a service-account app offers both `api` and `pubsub` and so
980
+ * carries two of them in one block, which two hardcoded id lookups could not express - they
981
+ * both reached for the same element and fought over it.
991
982
  */
992
983
  function checkScopesRadio() {
993
- let baseScopesAPIElm = document.getElementById('baseScopesAPI');
994
- let baseScopesPubsubElm = document.getElementById('baseScopesPubsub');
995
- let selectPubsubAppElm = document.getElementById('select-pubsub-app');
996
- let accountTypeCardGmail = document.getElementById('account-type-card-gmail');
997
- let accountTypeCardOutlook = document.getElementById('account-type-card-outlook');
998
-
999
- if (baseScopesAPIElm && selectPubsubAppElm) {
1000
- if (baseScopesAPIElm.checked) {
1001
- selectPubsubAppElm.classList.remove('hidden');
1002
- if (pubSubAppElm) {
1003
- pubSubAppElm.disabled = false;
1004
- }
1005
- } else {
1006
- selectPubsubAppElm.classList.add('hidden');
1007
- if (pubSubAppElm) {
1008
- pubSubAppElm.disabled = true;
1009
- }
1010
- }
984
+ let selected = document.querySelector('.base-scopes-radio:checked');
985
+ if (!selected) {
986
+ // A stored app's page renders its base scope as a static row and carries no radios at
987
+ // all, so the server already decided what is visible. Toggling against "nothing
988
+ // selected" would hide every section, including the Pub/Sub topic names and the
989
+ // Microsoft notification endpoints that page exists to show.
990
+ return;
1011
991
  }
1012
992
 
1013
- if (baseScopesPubsubElm && selectPubsubAppElm) {
1014
- if (baseScopesPubsubElm.checked) {
1015
- selectPubsubAppElm.classList.remove('hidden');
1016
- } else {
1017
- selectPubsubAppElm.classList.add('hidden');
993
+ let shownElm = null;
994
+ document.querySelectorAll('[data-base-scopes]').forEach(sectionElm => {
995
+ let shown = sectionElm.dataset.baseScopes === selected.value;
996
+ sectionElm.classList.toggle('hidden', !shown);
997
+ if (shown) {
998
+ shownElm = sectionElm;
1018
999
  }
1019
- }
1000
+ });
1020
1001
 
1021
- // Show/hide account type card based on API mode selection
1022
- if (baseScopesAPIElm) {
1023
- if (baseScopesAPIElm.checked) {
1024
- if (accountTypeCardGmail) {
1025
- accountTypeCardGmail.classList.remove('hidden');
1026
- }
1027
- if (accountTypeCardOutlook) {
1028
- accountTypeCardOutlook.classList.remove('hidden');
1029
- }
1030
- } else {
1031
- if (accountTypeCardGmail) {
1032
- accountTypeCardGmail.classList.add('hidden');
1033
- }
1034
- if (accountTypeCardOutlook) {
1035
- accountTypeCardOutlook.classList.add('hidden');
1036
- }
1037
- }
1002
+ if (pubSubAppElm) {
1003
+ // A disabled control is left out of the submitted form, which is how a hidden Pub/Sub
1004
+ // selection stays out of the payload instead of riding along. Only the select is touched
1005
+ // here - which options are selectable belongs to filterPubSubApps() alone.
1006
+ pubSubAppElm.disabled = !shownElm || !shownElm.contains(pubSubAppElm);
1038
1007
  }
1039
1008
 
1009
+ // The account type card describes what an API-based app can do with an account
1010
+ document.querySelectorAll('#account-type-card-gmail, #account-type-card-outlook').forEach(cardElm => {
1011
+ cardElm.classList.toggle('hidden', selected.value !== 'api');
1012
+ });
1040
1013
  }
1041
1014
 
1042
1015
  document.querySelectorAll('.base-scopes-radio').forEach(radioElm => {
@@ -0,0 +1,43 @@
1
+ {{!-- The Pub/Sub service account an API-based Gmail app uses to arm watches, shared by the
2
+ interactive `gmail` block and the `gmailService` one: both reach Gmail over the HTTP API, so both want
3
+ the same control, and the server-side `pubSubApp` field was never provider-specific.
4
+
5
+ `data-base-scopes="api"` is what reveals it - see checkScopesRadio() at the bottom of oauth_form.hbs. --}}
6
+
7
+ <div class="card-footer border-base-content/10 border-t px-6 py-4{{#unless baseScopesApi}} hidden{{/unless}}"
8
+ data-base-scopes="api">
9
+
10
+ <p class="mb-2">
11
+ For faster webhook notifications, select a Gmail service account with the Pub/Sub Admin role.
12
+ EmailEngine uses it to set up Google Cloud Pub/Sub for accounts managed by this app.
13
+ </p>
14
+
15
+ <p class="mb-2">
16
+ <strong>Note:</strong> This is optional but recommended. With a Pub/Sub service account, EmailEngine
17
+ receives changes in near real time. Without one, it falls back to polling each account about every 10
18
+ minutes, so webhooks for new, updated, or deleted emails (and bounce detection) still fire, just with up
19
+ to a 10-minute delay. Send-only accounts don't require this.
20
+ </p>
21
+
22
+ <label class="label-text" for="pubSubApp">Select service account to manage webhooks (optional). The service
23
+ account must be for the same Google Cloud Project.</label>
24
+ <select class="select w-full{{#if errors.pubSubApp}} is-invalid{{/if}}" id="pubSubApp"
25
+ name="pubSubApp" {{#unless baseScopesApi}}disabled{{/unless}}>
26
+
27
+ <option value="">Select the service account for your project</option>
28
+
29
+ {{!-- Nothing disables an option here: the select carries that for the whole control, and
30
+ filterPubSubApps() in oauth_form.hbs owns the per-option state so the two cannot fight. An
31
+ {{#unless baseScopesApi}} inside this {{#each}} resolved against the ITEM rather than the page,
32
+ so it shipped `disabled` on every option in every mode. --}}
33
+ {{#each pubSubApps}}
34
+ <option value="{{id}}" data-project="{{googleProjectId}}" {{#if selected}}selected{{/if}}>{{name}}{{#if
35
+ description}} -
36
+ {{description}}{{/if}} [{{googleProjectId}}]</option>
37
+ {{/each}}
38
+
39
+ </select>
40
+ {{#if errors.pubSubApp}}
41
+ <span class="helper-text text-error">{{errors.pubSubApp}}</span>
42
+ {{/if}}
43
+ </div>