@remit/imap-worker 0.0.11 → 0.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/imap-worker",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
@@ -8,6 +8,7 @@ import {
8
8
  isCursorRebuildNeeded,
9
9
  MailboxCursorPausedError,
10
10
  PlacementMoveService,
11
+ QuarantineService,
11
12
  resolveExhaustedBodySyncFailures,
12
13
  } from "@remit/mailbox-service";
13
14
  import { env } from "expect-env";
@@ -20,6 +21,7 @@ import {
20
21
  import type { SyncMessageBodyEvent } from "../events.js";
21
22
  import { withOAuthLifecycle } from "../with-oauth-lifecycle.js";
22
23
  import { buildLifecycleDeps } from "../with-oauth-lifecycle-deps.js";
24
+ import { workerVersion } from "../worker-version.js";
23
25
 
24
26
  const bodySyncEnabledParameterName = env.BODY_SYNC_ENABLED_PARAMETER_NAME;
25
27
 
@@ -151,6 +153,8 @@ export const syncMessageBody = async (
151
153
  messageLabel: messageLabelService,
152
154
  storage,
153
155
  secrets,
156
+ mailboxSpecialUse: mailboxSpecialUseRepository,
157
+ quarantine: quarantineRepository,
154
158
  } = await getClient();
155
159
 
156
160
  const account = await accountService.get(accountId);
@@ -234,6 +238,17 @@ export const syncMessageBody = async (
234
238
  log,
235
239
  placementConfig,
236
240
  filterConfig,
241
+ {
242
+ quarantineService: new QuarantineService(
243
+ quarantineRepository,
244
+ mailboxSpecialUseRepository,
245
+ workerVersion(),
246
+ log,
247
+ ),
248
+ mailboxId,
249
+ uidValidity: mailbox.uidValidity ?? 0,
250
+ attempts: receiveCount,
251
+ },
237
252
  );
238
253
 
239
254
  // Guard at the openBox choke point (epic #1281 invariants 3 & 5). The
@@ -5,9 +5,11 @@ import type {
5
5
  IAddressRepository,
6
6
  IEnvelopeRepository,
7
7
  IMailboxRepository,
8
+ IMailboxSpecialUseRepository,
8
9
  IMessageFlagPushRepository,
9
10
  IMessageFlagRepository,
10
11
  IMessageRepository,
12
+ IQuarantineRepository,
11
13
  IThreadMessageRepository,
12
14
  IUnitOfWork,
13
15
  } from "@remit/data-ports";
@@ -19,6 +21,7 @@ import {
19
21
  MailConnectionError,
20
22
  type MailCredentials,
21
23
  MessageSyncService,
24
+ QuarantineService,
22
25
  type SyncedMessage,
23
26
  } from "@remit/mailbox-service";
24
27
  import pMap from "p-map";
@@ -31,6 +34,7 @@ import type {
31
34
  } from "../events.js";
32
35
  import { withOAuthLifecycle } from "../with-oauth-lifecycle.js";
33
36
  import { buildLifecycleDeps } from "../with-oauth-lifecycle-deps.js";
37
+ import { workerVersion } from "../worker-version.js";
34
38
 
35
39
  // One SYNC_MESSAGE_BODY event maps to one ranged UID FETCH on the consumer.
36
40
  export const BODY_BATCH_SIZE = 200;
@@ -70,6 +74,8 @@ export const syncMessages = async (
70
74
  address: addressService,
71
75
  threadMessage: threadMessageService,
72
76
  mailboxLock: mailboxLockService,
77
+ mailboxSpecialUse: mailboxSpecialUseService,
78
+ quarantine: quarantineService,
73
79
  flagPush: flagPushMarkerService,
74
80
  messageFlag: messageFlagService,
75
81
  unitOfWork,
@@ -138,6 +144,8 @@ export const syncMessages = async (
138
144
  envelopeService,
139
145
  addressService,
140
146
  threadMessageService,
147
+ mailboxSpecialUseService,
148
+ quarantineService,
141
149
  flagPushMarkerService,
142
150
  messageFlagService,
143
151
  unitOfWork,
@@ -181,6 +189,8 @@ interface SyncDeps {
181
189
  envelopeService: IEnvelopeRepository;
182
190
  addressService: IAddressRepository;
183
191
  threadMessageService: IThreadMessageRepository;
192
+ mailboxSpecialUseService: IMailboxSpecialUseRepository;
193
+ quarantineService: IQuarantineRepository;
184
194
  flagPushMarkerService: IMessageFlagPushRepository;
185
195
  messageFlagService: IMessageFlagRepository;
186
196
  unitOfWork?: IUnitOfWork;
@@ -272,6 +282,8 @@ const syncMailboxMessages = async (
272
282
  envelopeService,
273
283
  addressService,
274
284
  threadMessageService,
285
+ mailboxSpecialUseService,
286
+ quarantineService,
275
287
  flagPushMarkerService,
276
288
  messageFlagService,
277
289
  unitOfWork,
@@ -307,6 +319,12 @@ const syncMailboxMessages = async (
307
319
  unitOfWork,
308
320
  flagPushMarkerService,
309
321
  messageFlagService,
322
+ new QuarantineService(
323
+ quarantineService,
324
+ mailboxSpecialUseService,
325
+ workerVersion(),
326
+ log,
327
+ ),
310
328
  );
311
329
 
312
330
  // Connect once, reuse for the entire sync operation
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The build of this worker, stamped onto a quarantine record so a maintainer
3
+ * reading a filed report knows which commit failed to read the message.
4
+ *
5
+ * Deliberately not the client's `APP_SHA`: that is the web build, and pointing
6
+ * a maintainer at it for a backend parse failure sends them to the wrong
7
+ * commit. The container bundle replaces this read at build time (see
8
+ * `npm-scripts/docker-bundle.mjs`); outside an image build it falls back to the
9
+ * CI-provided SHA, then to `dev`, so a local run is labelled honestly rather
10
+ * than claiming a release it is not.
11
+ */
12
+ export const workerVersion = (): string =>
13
+ process.env.REMIT_WORKER_SHA || process.env.GITHUB_SHA || "dev";