emailengine-app 2.83.1 → 2.84.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +30 -0
- package/README.md +1 -1
- package/SECURITY.md +126 -47
- package/data/google-crawlers.json +1 -1
- package/gettext-extract.js +95 -15
- package/lib/api-routes/outbox-routes.js +132 -9
- package/lib/api-routes/permission-map.js +11 -1
- package/lib/consts.js +3 -5
- package/lib/email-client/base-client.js +44 -20
- package/lib/email-client/credential-errors.js +3 -31
- package/lib/email-client/imap/idle-settings.js +44 -0
- package/lib/email-client/imap/mailbox.js +19 -7
- package/lib/email-client/imap-client.js +3 -21
- package/lib/email-client/smtp-pool-manager.js +25 -6
- package/lib/enum-descriptions.js +7 -0
- package/lib/export.js +46 -42
- package/lib/field-usage.js +4 -0
- package/lib/handlebars-helpers.js +4 -0
- package/lib/imapproxy/imap-core/lib/commands/starttls.js +4 -2
- package/lib/imapproxy/imap-core/lib/imap-server.js +44 -11
- package/lib/imapproxy/proxy-handoff.js +10 -1
- package/lib/logger.js +3 -2
- package/lib/message-port-stream.js +23 -0
- package/lib/network-errors.js +50 -0
- package/lib/oauth/gmail.js +5 -1
- package/lib/oauth/mail-ru.js +5 -1
- package/lib/oauth/outlook.js +5 -1
- package/lib/oauth/pubsub/google.js +3 -2
- package/lib/oauth/token-fetch.js +2 -3
- package/lib/outbox.js +338 -10
- package/lib/queue-browser/definitions.js +132 -0
- package/lib/queue-browser/format.js +387 -0
- package/lib/queue-browser/index.js +568 -0
- package/lib/queue-job-actions.js +75 -0
- package/lib/queue-retention.js +53 -1
- package/lib/routes-ui.js +5 -0
- package/lib/schemas.js +42 -2
- package/lib/security-headers.js +2 -24
- package/lib/sub-script.js +10 -3
- package/lib/token-permission-view.js +1 -1
- package/lib/tools.js +16 -2
- package/lib/ui-routes/account-routes.js +6 -0
- package/lib/ui-routes/imap-idle-field.js +42 -0
- package/lib/ui-routes/queue-routes.js +371 -0
- package/lib/utils/status-error.js +21 -0
- package/package.json +18 -20
- package/prepare-bundle-deps.sh +1 -1
- package/sbom.json +1 -1
- package/server.js +10 -0
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +2 -0
- package/static/js/queues.js +117 -0
- package/static/licenses.html +127 -251
- package/translations/README.md +3 -2
- package/translations/messages.pot +280 -265
- package/views/accounts/account.hbs +31 -0
- package/views/accounts/edit.hbs +2 -0
- package/views/config/service.hbs +1 -2
- package/views/dashboard.hbs +2 -2
- package/views/partials/queue_cell_account.hbs +20 -0
- package/views/partials/queue_cell_failure.hbs +6 -0
- package/views/partials/queue_clean_items.hbs +9 -0
- package/views/partials/queue_clean_modal.hbs +9 -0
- package/views/partials/queue_entry_actions.hbs +41 -0
- package/views/partials/queue_job_actions.hbs +15 -0
- package/views/partials/queue_pause_controls.hbs +18 -0
- package/views/partials/queue_retention_note.hbs +49 -0
- package/views/partials/queue_rows_export.hbs +58 -0
- package/views/partials/queue_rows_notify.hbs +73 -0
- package/views/partials/queue_rows_submit.hbs +70 -0
- package/views/partials/side_menu.hbs +1 -1
- package/views/partials/ui/tooltip.hbs +5 -3
- package/views/queues/index.hbs +104 -0
- package/views/queues/job.hbs +224 -0
- package/views/queues/queue.hbs +93 -0
- package/views/webhooks/webhook.hbs +3 -0
- package/workers/api.js +0 -4
- package/workers/imap.js +10 -3
- package/workers/smtp.js +16 -1
- package/workers/submit.js +19 -5
- package/workers/webhooks.js +13 -0
- package/lib/api-routes/bull-board-routes.js +0 -56
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
{{!-- One queue entry. Leads with what it is and what happened to it; the raw BullMQ record is
|
|
2
|
+
at the bottom, collapsed, for support cases. --}}
|
|
3
|
+
{{> ui/breadcrumb parentHref="/admin/queues" parentLabel="Queues" midHref=listHref midLabel=queue.label current=entry.title class="mb-6"}}
|
|
4
|
+
|
|
5
|
+
{{!-- The actions sit in the page header, at the right, as on the queue page: the one that moves
|
|
6
|
+
the entry on (send now, retry) as a button, the removal in the kebab at the end of the row,
|
|
7
|
+
where its menu opens leftward over the content. They are plain POST forms, so they work
|
|
8
|
+
before the page script has run and without it. An entry a worker is running offers nothing;
|
|
9
|
+
its state badge says so. --}}
|
|
10
|
+
{{#> ui/page-header title=entry.title icon=queue.icon badgeLabel=entry.stateInfo.label badgeVariant=entry.stateInfo.variant class="mb-6"}}
|
|
11
|
+
{{> ui/btn label="Back to list" href=listHref bare=true style="soft" size="sm" icon="icon-[tabler--arrow-left]"}}
|
|
12
|
+
{{#if entry.canPromote}}
|
|
13
|
+
<form method="post" action="{{entry.url}}/promote">
|
|
14
|
+
<input type="hidden" name="crumb" value="{{crumb}}">
|
|
15
|
+
<input type="hidden" name="next" value="{{currentUrl}}">
|
|
16
|
+
{{> ui/btn label="Send now" type="submit" variant="primary" size="sm" icon="icon-[tabler--send]"}}
|
|
17
|
+
</form>
|
|
18
|
+
{{/if}}
|
|
19
|
+
{{#if entry.canRetry}}
|
|
20
|
+
<form method="post" action="{{entry.url}}/retry">
|
|
21
|
+
<input type="hidden" name="crumb" value="{{crumb}}">
|
|
22
|
+
<input type="hidden" name="next" value="{{currentUrl}}">
|
|
23
|
+
{{> ui/btn label="Retry" type="submit" variant="primary" size="sm" icon="icon-[tabler--refresh]"}}
|
|
24
|
+
</form>
|
|
25
|
+
{{else if entry.retryBlockedReason}}
|
|
26
|
+
{{!-- A failed message whose content is gone keeps the button, disabled, so the reader learns why
|
|
27
|
+
from the tooltip rather than wondering where Retry went --}}
|
|
28
|
+
{{#> ui/tooltip text=entry.retryBlockedReason placement="bottom"}}
|
|
29
|
+
{{> ui/btn label="Retry" variant="primary" size="sm" icon="icon-[tabler--refresh]" disabled=true}}
|
|
30
|
+
{{/ui/tooltip}}
|
|
31
|
+
{{/if}}
|
|
32
|
+
{{#if entry.canRemove}}
|
|
33
|
+
{{> ui/overflow-menu label="More entry actions" deleteLabel="Remove from queue" deleteModal="#removeJob"}}
|
|
34
|
+
{{/if}}
|
|
35
|
+
{{/ui/page-header}}
|
|
36
|
+
|
|
37
|
+
{{#if entry.failure}}
|
|
38
|
+
{{#if entry.isRetryWait}}
|
|
39
|
+
{{#> ui/alert-banner variant="warning" title=(concat "Last attempt failed: " entry.failure.label)}}
|
|
40
|
+
<div class="break-words text-sm"><code>{{entry.failure.reason}}</code></div>
|
|
41
|
+
<div class="text-sm mt-1">Attempt {{entry.attemptsLabel}}. The next one runs <span class="relative-time" data-time="{{entry.dueAt}}"></span>, or now if you promote it.</div>
|
|
42
|
+
{{/ui/alert-banner}}
|
|
43
|
+
{{else}}
|
|
44
|
+
{{#> ui/alert-banner variant="error" title=entry.failure.label}}
|
|
45
|
+
<div class="break-words text-sm"><code>{{entry.failure.reason}}</code></div>
|
|
46
|
+
<div class="text-sm mt-1">
|
|
47
|
+
{{#equals entry.state "failed"}}
|
|
48
|
+
{{#if entry.failure.permanent}}Given up on without using the remaining attempts, because retrying could not have helped.{{else}}Given up on after {{entry.attemptsLabel}} attempts.{{/if}}
|
|
49
|
+
{{#equals queue.name "submit"}}
|
|
50
|
+
{{#if entry.hasContent}}The message content is still stored, so it can be retried from here.{{else}}{{entry.retryBlockedReason}}{{/if}}
|
|
51
|
+
{{/equals}}
|
|
52
|
+
{{else}}
|
|
53
|
+
Attempt {{entry.attemptsLabel}}.
|
|
54
|
+
{{/equals}}
|
|
55
|
+
</div>
|
|
56
|
+
{{/ui/alert-banner}}
|
|
57
|
+
{{/if}}
|
|
58
|
+
{{/if}}
|
|
59
|
+
|
|
60
|
+
{{#> ui/card}}
|
|
61
|
+
<dl class="ee-dl">
|
|
62
|
+
{{#equals queue.name "submit"}}
|
|
63
|
+
<dt>Account</dt>
|
|
64
|
+
<dd>{{> queue_cell_account account=entry.account accountKnown=entry.accountKnown}}</dd>
|
|
65
|
+
|
|
66
|
+
{{#if entry.from}}
|
|
67
|
+
<dt>From</dt>
|
|
68
|
+
<dd>{{entry.from}}</dd>
|
|
69
|
+
{{/if}}
|
|
70
|
+
|
|
71
|
+
{{#if entry.to}}
|
|
72
|
+
<dt>To</dt>
|
|
73
|
+
<dd>{{#each entry.to}}<div>{{this}}</div>{{/each}}</dd>
|
|
74
|
+
{{/if}}
|
|
75
|
+
|
|
76
|
+
<dt>Subject</dt>
|
|
77
|
+
<dd>{{#if entry.subject}}{{entry.subject}}{{else}}<span class="text-base-content/60">(no subject)</span>{{/if}}</dd>
|
|
78
|
+
|
|
79
|
+
{{#if entry.messageId}}
|
|
80
|
+
<dt>Message-ID</dt>
|
|
81
|
+
<dd><code class="break-all">{{entry.messageId}}</code></dd>
|
|
82
|
+
{{/if}}
|
|
83
|
+
|
|
84
|
+
<dt>Queue ID</dt>
|
|
85
|
+
<dd>{{> ui/copy-field id="queue-id" value=entry.id ariaLabel="Queue ID" small=true join=true class="max-w-md"}}</dd>
|
|
86
|
+
|
|
87
|
+
{{#if entry.gateway}}
|
|
88
|
+
<dt>Gateway</dt>
|
|
89
|
+
<dd><a href="/admin/gateways/gateway/{{urlpart entry.gateway}}" class="link link-animated">{{entry.gateway}}</a></dd>
|
|
90
|
+
{{/if}}
|
|
91
|
+
|
|
92
|
+
{{#if entry.source}}
|
|
93
|
+
<dt>Submitted through</dt>
|
|
94
|
+
<dd>{{entry.source}}</dd>
|
|
95
|
+
{{/if}}
|
|
96
|
+
|
|
97
|
+
{{#if entry.idempotencyKey}}
|
|
98
|
+
<dt>Idempotency key</dt>
|
|
99
|
+
<dd><code>{{entry.idempotencyKey}}</code></dd>
|
|
100
|
+
{{/if}}
|
|
101
|
+
{{else}}
|
|
102
|
+
{{#equals queue.name "notify"}}
|
|
103
|
+
<dt>Event</dt>
|
|
104
|
+
<dd><code>{{entry.event}}</code></dd>
|
|
105
|
+
|
|
106
|
+
<dt>Account</dt>
|
|
107
|
+
<dd>{{> queue_cell_account account=entry.account accountKnown=entry.accountKnown instance="Instance event"}}</dd>
|
|
108
|
+
|
|
109
|
+
<dt>Target</dt>
|
|
110
|
+
<dd>
|
|
111
|
+
{{#if entry.routeId}}
|
|
112
|
+
{{#if entry.routeKnown}}
|
|
113
|
+
Webhook route <a href="/admin/webhooks/webhook/{{urlpart entry.routeId}}" class="link link-animated">{{entry.routeName}}</a>{{#if entry.hasMapping}} <span class="text-base-content/60">(payload mapped by the route)</span>{{/if}}
|
|
114
|
+
{{else}}
|
|
115
|
+
{{> ui/badge label="Route deleted" variant="warning" soft=true}} <span class="text-base-content/60">The route this delivery was queued for no longer exists, so the worker skips it.</span>
|
|
116
|
+
{{/if}}
|
|
117
|
+
{{else}}
|
|
118
|
+
<span>The default webhook: the account's own URL if it has one, otherwise the instance setting. Resolved when the delivery runs.</span>
|
|
119
|
+
{{/if}}
|
|
120
|
+
</dd>
|
|
121
|
+
|
|
122
|
+
{{#if entry.about}}
|
|
123
|
+
<dt>About</dt>
|
|
124
|
+
<dd>{{entry.about}}</dd>
|
|
125
|
+
{{/if}}
|
|
126
|
+
|
|
127
|
+
{{#if entry.path}}
|
|
128
|
+
<dt>Folder</dt>
|
|
129
|
+
<dd><code>{{entry.path}}</code>{{#if entry.specialUse}} <span class="text-base-content/60">{{entry.specialUse}}</span>{{/if}}</dd>
|
|
130
|
+
{{/if}}
|
|
131
|
+
|
|
132
|
+
<dt>Payload</dt>
|
|
133
|
+
<dd>{{entry.payloadSizeLabel}}</dd>
|
|
134
|
+
|
|
135
|
+
<dt>Job ID</dt>
|
|
136
|
+
<dd><code>{{entry.id}}</code></dd>
|
|
137
|
+
{{else}}
|
|
138
|
+
<dt>Export</dt>
|
|
139
|
+
<dd><code>{{entry.exportId}}</code></dd>
|
|
140
|
+
|
|
141
|
+
<dt>Account</dt>
|
|
142
|
+
<dd>{{> queue_cell_account account=entry.account accountKnown=entry.accountKnown}}{{#if entry.accountKnown}} <span class="text-base-content/60">(manage the export from the account page)</span>{{/if}}</dd>
|
|
143
|
+
{{/equals}}
|
|
144
|
+
{{/equals}}
|
|
145
|
+
</dl>
|
|
146
|
+
|
|
147
|
+
<hr class="my-4">
|
|
148
|
+
|
|
149
|
+
<dl class="ee-dl">
|
|
150
|
+
<dt>Queued</dt>
|
|
151
|
+
<dd><span class="local-date-time" data-time="{{entry.created}}"></span> <span class="text-base-content/60">(<span class="relative-time" data-time="{{entry.created}}"></span>)</span></dd>
|
|
152
|
+
|
|
153
|
+
{{#if entry.isScheduledSend}}
|
|
154
|
+
<dt>Scheduled for</dt>
|
|
155
|
+
<dd><span class="local-date-time" data-time="{{entry.scheduled}}"></span> <span class="text-base-content/60">(<span class="relative-time" data-time="{{entry.scheduled}}"></span>)</span></dd>
|
|
156
|
+
{{/if}}
|
|
157
|
+
|
|
158
|
+
{{#if entry.processedOn}}
|
|
159
|
+
<dt>Last attempt started</dt>
|
|
160
|
+
<dd><span class="local-date-time" data-time="{{entry.processedOn}}"></span> <span class="text-base-content/60">(<span class="relative-time" data-time="{{entry.processedOn}}"></span>)</span></dd>
|
|
161
|
+
{{/if}}
|
|
162
|
+
|
|
163
|
+
{{#if entry.finishedOn}}
|
|
164
|
+
<dt>Finished</dt>
|
|
165
|
+
<dd><span class="local-date-time" data-time="{{entry.finishedOn}}"></span> <span class="text-base-content/60">(<span class="relative-time" data-time="{{entry.finishedOn}}"></span>)</span></dd>
|
|
166
|
+
{{/if}}
|
|
167
|
+
|
|
168
|
+
<dt>Attempts</dt>
|
|
169
|
+
<dd>{{entry.attemptsLabel}}{{#if entry.duration}} <span class="text-base-content/60">(last attempt took {{entry.duration}} ms)</span>{{/if}}</dd>
|
|
170
|
+
|
|
171
|
+
{{#if entry.isRetryWait}}
|
|
172
|
+
<dt>Next attempt</dt>
|
|
173
|
+
<dd><span class="local-date-time" data-time="{{entry.dueAt}}"></span> <span class="text-base-content/60">(<span class="relative-time" data-time="{{entry.dueAt}}"></span>, at the latest)</span></dd>
|
|
174
|
+
{{/if}}
|
|
175
|
+
|
|
176
|
+
{{#if entry.outcome.response}}
|
|
177
|
+
<dt>Server response</dt>
|
|
178
|
+
<dd><code class="break-all">{{entry.outcome.response}}</code></dd>
|
|
179
|
+
{{/if}}
|
|
180
|
+
|
|
181
|
+
{{#equals entry.outcome.status "delivered"}}
|
|
182
|
+
<dt>Delivered</dt>
|
|
183
|
+
<dd>The endpoint answered <code>{{entry.outcome.statusCode}}</code></dd>
|
|
184
|
+
{{/equals}}
|
|
185
|
+
</dl>
|
|
186
|
+
{{/ui/card}}
|
|
187
|
+
|
|
188
|
+
{{#> ui/details summary="Raw queue record" summarySmall="the job as BullMQ stores it"}}
|
|
189
|
+
<div class="space-y-4 text-sm">
|
|
190
|
+
<div>
|
|
191
|
+
<div class="label-text mb-1">Job name: <code>{{raw.name}}</code></div>
|
|
192
|
+
</div>
|
|
193
|
+
<div>
|
|
194
|
+
<div class="label-text mb-1">Data</div>
|
|
195
|
+
<pre class="ee-code-block"><code>{{json raw.data}}</code></pre>
|
|
196
|
+
</div>
|
|
197
|
+
<div>
|
|
198
|
+
<div class="label-text mb-1">Options</div>
|
|
199
|
+
<pre class="ee-code-block"><code>{{json raw.opts}}</code></pre>
|
|
200
|
+
</div>
|
|
201
|
+
{{#if raw.progress}}
|
|
202
|
+
<div>
|
|
203
|
+
<div class="label-text mb-1">Progress</div>
|
|
204
|
+
<pre class="ee-code-block"><code>{{json raw.progress}}</code></pre>
|
|
205
|
+
</div>
|
|
206
|
+
{{/if}}
|
|
207
|
+
{{#if raw.returnvalue}}
|
|
208
|
+
<div>
|
|
209
|
+
<div class="label-text mb-1">Return value</div>
|
|
210
|
+
<pre class="ee-code-block"><code>{{json raw.returnvalue}}</code></pre>
|
|
211
|
+
</div>
|
|
212
|
+
{{/if}}
|
|
213
|
+
{{#if raw.stacktrace}}
|
|
214
|
+
<div>
|
|
215
|
+
<div class="label-text mb-1">Stack traces of the failed attempts</div>
|
|
216
|
+
<pre class="ee-code-block"><code>{{raw.stacktrace}}</code></pre>
|
|
217
|
+
</div>
|
|
218
|
+
{{/if}}
|
|
219
|
+
</div>
|
|
220
|
+
{{/ui/details}}
|
|
221
|
+
|
|
222
|
+
{{> queue_job_actions removeAction=(concat entry.url "/remove") removeName=entry.title}}
|
|
223
|
+
|
|
224
|
+
<script data-cfasync="false" src="/static/js/queues.js" defer></script>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
{{!-- One queue, one state at a time. The state tabs are links (the page is server-rendered per
|
|
2
|
+
state), the listing is the rows of that state, and the search is a bounded scan of it -
|
|
3
|
+
the notice under the toolbar says how far it looked. --}}
|
|
4
|
+
{{> ui/breadcrumb parentHref="/admin/queues" parentLabel="Queues" current=queue.label class="mb-6"}}
|
|
5
|
+
|
|
6
|
+
{{#> ui/page-header title=queue.title icon=queue.icon subtitle=queue.description class="mb-6"}}
|
|
7
|
+
<span data-queue-paused="{{queue.name}}" class="{{#unless queue.isPaused}}hidden{{/unless}}">
|
|
8
|
+
{{> ui/badge label="Paused" variant="warning" title="Workers take nothing new from this queue until it is resumed"}}
|
|
9
|
+
</span>
|
|
10
|
+
{{> ui/btn label="Refresh" href=currentUrl bare=true style="soft" size="sm" icon="icon-[tabler--refresh]"}}
|
|
11
|
+
{{> queue_pause_controls name=queue.name isPaused=queue.isPaused next=currentUrl}}
|
|
12
|
+
{{#> ui/overflow-menu label="More queue actions"}}
|
|
13
|
+
<li><a class="dropdown-item" href="/admin/queues">All queues</a></li>
|
|
14
|
+
{{> queue_clean_items name=queue.name title=queue.title nounPlural=queue.nounPlural}}
|
|
15
|
+
{{/ui/overflow-menu}}
|
|
16
|
+
{{/ui/page-header}}
|
|
17
|
+
|
|
18
|
+
<div data-queue-paused="{{queue.name}}" class="{{#unless queue.isPaused}}hidden{{/unless}}">
|
|
19
|
+
{{#> ui/alert-banner variant="warning" title="This queue is paused" icon="icon-[tabler--player-pause]"}}
|
|
20
|
+
<div class="text-sm">New entries keep arriving and wait here until the queue is resumed. An attempt that was already running finishes.</div>
|
|
21
|
+
{{/ui/alert-banner}}
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<nav class="tabs tabs-bordered mb-6" aria-label="Entries by state">
|
|
25
|
+
{{#each states}}
|
|
26
|
+
<a class="tab{{#if active}} tab-active{{/if}}" href="{{url}}" title="{{description}}">{{label}}
|
|
27
|
+
<span class="badge badge-sm badge-soft ms-1 {{#if active}}badge-{{eeColor variant}}{{else}}badge-neutral{{/if}}" data-queue-count="{{@root.queue.name}}:{{name}}">{{formatInteger count @root.userLocale}}</span></a>
|
|
28
|
+
{{/each}}
|
|
29
|
+
</nav>
|
|
30
|
+
|
|
31
|
+
<div class="card bg-base-100 shadow-md mb-6">
|
|
32
|
+
<div class="card-header flex flex-wrap items-center justify-between gap-3">
|
|
33
|
+
<div class="min-w-0">
|
|
34
|
+
<h6 class="card-title text-primary mb-0">{{state.label}}</h6>
|
|
35
|
+
<p class="text-base-content/60 text-sm mt-1 mb-0">{{state.description}}.</p>
|
|
36
|
+
{{> queue_retention_note}}
|
|
37
|
+
</div>
|
|
38
|
+
<form method="get" action="/admin/queues/{{queue.name}}" class="flex items-center gap-2" role="search">
|
|
39
|
+
<input type="hidden" name="state" value="{{state.name}}">
|
|
40
|
+
{{#if filter.account}}<input type="hidden" name="account" value="{{filter.account}}">{{/if}}
|
|
41
|
+
{{#if filter.route}}<input type="hidden" name="route" value="{{filter.route}}">{{/if}}
|
|
42
|
+
{{> ui/search-input name="query" value=filter.query placeholder=queue.searchHint class="w-72"}}
|
|
43
|
+
{{> ui/btn label="Search" type="submit" variant="neutral" style="soft" size="sm"}}
|
|
44
|
+
</form>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
{{#if filter.active}}
|
|
48
|
+
{{!-- What was searched, in numbers the reader can trust: the scan is bounded, and a search
|
|
49
|
+
that stopped short of the oldest entries says so instead of reporting zero matches as
|
|
50
|
+
if there were none --}}
|
|
51
|
+
<div class="border-base-content/10 flex flex-wrap items-center justify-between gap-2 border-b px-6 py-3 text-sm">
|
|
52
|
+
<span>
|
|
53
|
+
{{#if filter.label}}{{filter.label}}{{else}}Entries{{/if}}{{#if filter.query}} matching <strong>“{{filter.query}}”</strong>{{/if}}:
|
|
54
|
+
<strong>{{formatInteger listing.total userLocale}}</strong> of the {{formatInteger listing.scanned userLocale}} {{state.label}} entries searched{{#if listing.scanLimited}}.
|
|
55
|
+
Only the {{formatInteger scanLimit userLocale}} newest of {{formatInteger listing.stateTotal userLocale}} were searched{{/if}}.
|
|
56
|
+
</span>
|
|
57
|
+
<a href="{{clearHref}}" class="link link-animated">Clear search</a>
|
|
58
|
+
</div>
|
|
59
|
+
{{/if}}
|
|
60
|
+
|
|
61
|
+
{{#if listing.entries}}
|
|
62
|
+
<div class="overflow-x-auto">
|
|
63
|
+
{{#equals queue.name "submit"}}
|
|
64
|
+
{{> queue_rows_submit}}
|
|
65
|
+
{{else}}
|
|
66
|
+
{{#equals queue.name "notify"}}
|
|
67
|
+
{{> queue_rows_notify}}
|
|
68
|
+
{{else}}
|
|
69
|
+
{{> queue_rows_export}}
|
|
70
|
+
{{/equals}}
|
|
71
|
+
{{/equals}}
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
{{> ui/pagination showPaging=showPaging prevPage=prevPage nextPage=nextPage pageLinks=pageLinks}}
|
|
75
|
+
{{else}}
|
|
76
|
+
<div class="card-body">
|
|
77
|
+
{{#if filter.active}}
|
|
78
|
+
{{#> ui/empty-state icon="icon-[tabler--search-off]" title=(concat "No " state.name " " queue.nounPlural " match")}}
|
|
79
|
+
Try another search, or <a href="{{clearHref}}" class="link link-animated">show every {{state.name}} entry</a>.
|
|
80
|
+
{{/ui/empty-state}}
|
|
81
|
+
{{else}}
|
|
82
|
+
{{#> ui/empty-state icon=queue.icon title=(concat "No " state.name " " queue.nounPlural)}}
|
|
83
|
+
{{state.description}}.
|
|
84
|
+
{{/ui/empty-state}}
|
|
85
|
+
{{/if}}
|
|
86
|
+
</div>
|
|
87
|
+
{{/if}}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
{{> queue_job_actions}}
|
|
91
|
+
{{> queue_clean_modal}}
|
|
92
|
+
|
|
93
|
+
<script data-cfasync="false" src="/static/js/queues.js" defer></script>
|
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
{{#> ui/tooltip text="How many times this route has been triggered"}}
|
|
47
47
|
{{> ui/badge label=webhook.tcount variant="neutral" soft=true}}
|
|
48
48
|
{{/ui/tooltip}}
|
|
49
|
+
<a href="/admin/queues/notify?state=failed&route={{urlpart webhook.id}}" class="link link-animated text-sm ms-2">Failed deliveries</a>
|
|
50
|
+
<span class="text-base-content/40 text-sm">|</span>
|
|
51
|
+
<a href="/admin/queues/notify?route={{urlpart webhook.id}}" class="link link-animated text-sm">Waiting</a>
|
|
49
52
|
</dd>
|
|
50
53
|
|
|
51
54
|
{{#if webhook.customHeaders}}
|
package/workers/api.js
CHANGED
|
@@ -115,7 +115,6 @@ const {
|
|
|
115
115
|
} = consts;
|
|
116
116
|
|
|
117
117
|
const registerApiRoutes = require('../lib/api-routes');
|
|
118
|
-
const bullBoardRoutes = require('../lib/api-routes/bull-board-routes');
|
|
119
118
|
const { securityHeadersExt, attachSecurityContext, isAdminPath, isMachineRoute, isSecureOrigin, CSP_MODES } = require('../lib/security-headers');
|
|
120
119
|
const { registerHandlebarsHelpers } = require('../lib/handlebars-helpers');
|
|
121
120
|
|
|
@@ -3263,9 +3262,6 @@ const init = async () => {
|
|
|
3263
3262
|
// setup web UI
|
|
3264
3263
|
routesUi(server, call);
|
|
3265
3264
|
|
|
3266
|
-
// setup "Bull board" routes
|
|
3267
|
-
await bullBoardRoutes({ server });
|
|
3268
|
-
|
|
3269
3265
|
server.route({
|
|
3270
3266
|
method: 'GET',
|
|
3271
3267
|
path: '/metrics',
|
package/workers/imap.js
CHANGED
|
@@ -418,10 +418,17 @@ class ConnectionHandler {
|
|
|
418
418
|
this.assignTokens.delete(account);
|
|
419
419
|
if (this.accounts.has(account)) {
|
|
420
420
|
let accountObject = this.accounts.get(account);
|
|
421
|
-
|
|
422
|
-
|
|
421
|
+
try {
|
|
422
|
+
if (accountObject.connection) {
|
|
423
|
+
await accountObject.connection.delete();
|
|
424
|
+
}
|
|
425
|
+
} finally {
|
|
426
|
+
// The account record is already gone and nothing retries the delete, so an entry
|
|
427
|
+
// left behind by a failed teardown would stay registered for the worker's lifetime
|
|
428
|
+
if (this.accounts.get(account) === accountObject) {
|
|
429
|
+
this.accounts.delete(account);
|
|
430
|
+
}
|
|
423
431
|
}
|
|
424
|
-
this.accounts.delete(account);
|
|
425
432
|
}
|
|
426
433
|
}
|
|
427
434
|
|
package/workers/smtp.js
CHANGED
|
@@ -32,6 +32,10 @@ config.service = config.service || {};
|
|
|
32
32
|
|
|
33
33
|
const { DEFAULT_MAX_SMTP_MESSAGE_SIZE } = require('../lib/consts');
|
|
34
34
|
|
|
35
|
+
// On shutdown, how long open sessions get before they are told 421 and closed. Shorter than
|
|
36
|
+
// WORKER_DRAIN_TIMEOUT in server.js, so the 421 goes out before the thread is terminated
|
|
37
|
+
const SMTP_CLOSE_TIMEOUT = 5 * 1000;
|
|
38
|
+
|
|
35
39
|
const DEFAULT_EENGINE_TIMEOUT = 10 * 1000;
|
|
36
40
|
|
|
37
41
|
const MAX_SMTP_MESSAGE_SIZE = getByteSize(readEnvValue('EENGINE_MAX_SMTP_MESSAGE_SIZE') || config.smtp.maxMessageSize) || DEFAULT_MAX_SMTP_MESSAGE_SIZE;
|
|
@@ -133,7 +137,8 @@ async function init() {
|
|
|
133
137
|
banner: 'EmailEngine MSA',
|
|
134
138
|
size: MAX_SMTP_MESSAGE_SIZE,
|
|
135
139
|
maxClients: SMTP_MAX_CLIENTS,
|
|
136
|
-
useProxy: await settings.get('smtpServerProxy')
|
|
140
|
+
useProxy: await settings.get('smtpServerProxy'),
|
|
141
|
+
closeTimeout: SMTP_CLOSE_TIMEOUT
|
|
137
142
|
};
|
|
138
143
|
|
|
139
144
|
// Reads what the API worker provisioned; this one never orders a certificate itself.
|
|
@@ -326,6 +331,16 @@ async function onCommand(command) {
|
|
|
326
331
|
|
|
327
332
|
case 'smtpReloadCertificates':
|
|
328
333
|
return await reloadCertificates();
|
|
334
|
+
|
|
335
|
+
// Shutdown drain. Signals reach the main thread only, so server.js forwards them here.
|
|
336
|
+
// Stops accepting connections and lets a submission halfway through DATA be queued and
|
|
337
|
+
// answered, instead of cutting it at process exit: a client that never sees the 250 for
|
|
338
|
+
// a message that was already queued sends it again
|
|
339
|
+
case 'close':
|
|
340
|
+
if (smtpServer) {
|
|
341
|
+
await new Promise(resolve => smtpServer.close(resolve));
|
|
342
|
+
}
|
|
343
|
+
return true;
|
|
329
344
|
default:
|
|
330
345
|
logger.debug({ msg: 'Unhandled command', command });
|
|
331
346
|
return 999;
|
package/workers/submit.js
CHANGED
|
@@ -19,7 +19,7 @@ const { redis, queueConf, submitQueue, logBullErrors } = require('../lib/db');
|
|
|
19
19
|
const { Worker, UnrecoverableError } = require('bullmq');
|
|
20
20
|
const { Account } = require('../lib/account');
|
|
21
21
|
const getSecret = require('../lib/get-secret');
|
|
22
|
-
const { decodeQueueEntry } = require('../lib/outbox');
|
|
22
|
+
const { decodeQueueEntry, retainFailedContent } = require('../lib/outbox');
|
|
23
23
|
|
|
24
24
|
const { EMAIL_FAILED_NOTIFY } = require('../lib/consts');
|
|
25
25
|
|
|
@@ -296,7 +296,11 @@ const submitWorker = new Worker(
|
|
|
296
296
|
error: {
|
|
297
297
|
message: err.message,
|
|
298
298
|
code: err.code,
|
|
299
|
-
statusCode: err.statusCode
|
|
299
|
+
statusCode: err.statusCode,
|
|
300
|
+
// the SMTP reply code, when there was a reply: what decides whether the
|
|
301
|
+
// failure is permanent (lib/delivery-error.js), kept so the queue browser
|
|
302
|
+
// can say so without a rule of its own
|
|
303
|
+
responseCode: err.responseCode
|
|
300
304
|
},
|
|
301
305
|
networkRouting: err.info?.networkRouting
|
|
302
306
|
});
|
|
@@ -399,16 +403,26 @@ submitWorker.on('failed', async job => {
|
|
|
399
403
|
// BullMQ sets finishedOn only when the job is done for good, which covers both exhausting its
|
|
400
404
|
// attempts and being ended early by the UnrecoverableError thrown for a permanent rejection.
|
|
401
405
|
if (job.finishedOn) {
|
|
402
|
-
// this was final attempt
|
|
406
|
+
// this was the final attempt
|
|
403
407
|
if (!job.data.queueId && job.data.qId) {
|
|
404
408
|
// this value was used to be called qId
|
|
405
409
|
job.data.queueId = job.data.qId;
|
|
406
410
|
}
|
|
407
411
|
if (job.data && job.data.account && job.data.queueId) {
|
|
412
|
+
// The content stays stored, within the failed-content bounds, so the message can be
|
|
413
|
+
// retried from the queue browser or the outbox API. It used to be deleted here, which
|
|
414
|
+
// left a failed job that a retry could put back into the queue but that then found
|
|
415
|
+
// nothing to send.
|
|
408
416
|
try {
|
|
409
|
-
await
|
|
417
|
+
await retainFailedContent({ account: job.data.account, queueId: job.data.queueId, finishedOn: job.finishedOn, logger });
|
|
410
418
|
} catch (err) {
|
|
411
|
-
logger.error({
|
|
419
|
+
logger.error({
|
|
420
|
+
msg: 'Failed to retain the content of a failed message',
|
|
421
|
+
account: job.data.account,
|
|
422
|
+
queueId: job.data.queueId,
|
|
423
|
+
messageId: job.data.messageId,
|
|
424
|
+
err
|
|
425
|
+
});
|
|
412
426
|
}
|
|
413
427
|
// report as failed
|
|
414
428
|
try {
|
package/workers/webhooks.js
CHANGED
|
@@ -505,10 +505,23 @@ const notifyWorker = new Worker(
|
|
|
505
505
|
event: job.name,
|
|
506
506
|
status: 'success'
|
|
507
507
|
});
|
|
508
|
+
|
|
509
|
+
// Stored by BullMQ as the job's return value in the same write that completes it, so
|
|
510
|
+
// a retained completed job shows what the endpoint answered and how long it took
|
|
511
|
+
return { status: 'delivered', statusCode: status, duration };
|
|
508
512
|
} catch (err) {
|
|
509
513
|
// egress and redirect failures are thrown as UnrecoverableError below, so they are final as well
|
|
510
514
|
let isFinalAttempt = willBeFinalAttempt(job) || isUnrecoverableWebhookError(err);
|
|
511
515
|
|
|
516
|
+
// BullMQ keeps only the message of a failure on the job. The code and the HTTP status
|
|
517
|
+
// are what explain it, so they are recorded the way the submit worker records its own
|
|
518
|
+
// delivery errors, for the queue browser to read back
|
|
519
|
+
try {
|
|
520
|
+
await job.updateProgress({ status: 'error', error: { message: err.message, code: err.code, statusCode: err.statusCode }, duration });
|
|
521
|
+
} catch (progressErr) {
|
|
522
|
+
// ignore
|
|
523
|
+
}
|
|
524
|
+
|
|
512
525
|
logger[isFinalAttempt ? 'error' : 'warn']({
|
|
513
526
|
msg: 'Failed posting webhook',
|
|
514
527
|
action: 'webhook',
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { createBullBoard } = require('@bull-board/api');
|
|
4
|
-
const { BullMQAdapter } = require('@bull-board/api/bullMQAdapter');
|
|
5
|
-
const { HapiAdapter } = require('@bull-board/hapi');
|
|
6
|
-
const { notifyQueue, submitQueue } = require('../db');
|
|
7
|
-
const { BULL_BOARD_BASE_PATH } = require('../consts');
|
|
8
|
-
|
|
9
|
-
async function init(args) {
|
|
10
|
-
const { server } = args;
|
|
11
|
-
|
|
12
|
-
const serverAdapter = new HapiAdapter();
|
|
13
|
-
|
|
14
|
-
let queues = [
|
|
15
|
-
{
|
|
16
|
-
queue: notifyQueue,
|
|
17
|
-
prefix: 'Webhooks Queue - ',
|
|
18
|
-
description: 'This queue processes all email events that may trigger webhooks. Events that do not trigger a webhook are silently discarded.'
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
queue: submitQueue,
|
|
22
|
-
prefix: 'Submission Queue - ',
|
|
23
|
-
description: 'This queue contains emails that are scheduled to be sent.'
|
|
24
|
-
}
|
|
25
|
-
];
|
|
26
|
-
let queueAdapters = queues.map(queue => {
|
|
27
|
-
let adapter = new BullMQAdapter(queue.queue, {
|
|
28
|
-
description: queue.description,
|
|
29
|
-
prefix: queue.prefix
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
//adapter.setFormatter('name', job => `#Queue1 - ${job.name}`);
|
|
33
|
-
|
|
34
|
-
return adapter;
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
createBullBoard({
|
|
38
|
-
queues: queueAdapters,
|
|
39
|
-
serverAdapter,
|
|
40
|
-
options: {
|
|
41
|
-
uiConfig: {
|
|
42
|
-
boardTitle: 'Bull Board',
|
|
43
|
-
boardLogo: { path: '/static/logo.png', width: '28px', height: '28px' },
|
|
44
|
-
favIcon: { default: '/static/favicon/android-chrome-512x512.png', alternative: 'static/favicon/favicon-32x32.png' },
|
|
45
|
-
miscLinks: [{ text: 'Dashboard', url: '/admin' }]
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
serverAdapter.setBasePath(BULL_BOARD_BASE_PATH);
|
|
51
|
-
await server.register(serverAdapter.registerPlugin(), {
|
|
52
|
-
routes: { prefix: BULL_BOARD_BASE_PATH }
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
module.exports = init;
|