@remit/mailbox-service 0.0.104 → 0.0.105
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
package/src/index.ts
CHANGED
|
@@ -227,7 +227,7 @@ describe("MailboxManagementService.failDelete", () => {
|
|
|
227
227
|
]);
|
|
228
228
|
const service = new MailboxManagementService(repo);
|
|
229
229
|
|
|
230
|
-
await service.failDelete("acc-1", "mbx-1");
|
|
230
|
+
await service.failDelete("acc-1", "mbx-1", "Permission denied");
|
|
231
231
|
|
|
232
232
|
assert.equal(byId.get("mbx-1")?.syncStatus, MailboxSyncStatus.failed);
|
|
233
233
|
assert.equal(byId.get("mbx-1")?.fullPath, "Receipts");
|
|
@@ -239,7 +239,7 @@ describe("MailboxManagementService.failDelete", () => {
|
|
|
239
239
|
const service = new MailboxManagementService(repo);
|
|
240
240
|
|
|
241
241
|
await assert.rejects(
|
|
242
|
-
service.failDelete("acc-1", "mbx-1"),
|
|
242
|
+
service.failDelete("acc-1", "mbx-1", "Permission denied"),
|
|
243
243
|
(error: unknown) => (error as Error).name === "NotFoundError",
|
|
244
244
|
);
|
|
245
245
|
});
|
|
@@ -598,6 +598,7 @@ export class MailboxManagementService {
|
|
|
598
598
|
mailboxId: string,
|
|
599
599
|
oldPath: string,
|
|
600
600
|
newPath: string,
|
|
601
|
+
reason: string,
|
|
601
602
|
): Promise<void> => {
|
|
602
603
|
const root = await this.mailboxService
|
|
603
604
|
.get(accountId, mailboxId)
|
|
@@ -643,6 +644,7 @@ export class MailboxManagementService {
|
|
|
643
644
|
from: [MailboxSyncStatus.pending],
|
|
644
645
|
wherePendingPath: row.pendingPath,
|
|
645
646
|
to: MailboxSyncStatus.failed,
|
|
647
|
+
set: { syncFailureReason: reason },
|
|
646
648
|
},
|
|
647
649
|
);
|
|
648
650
|
this.log.info(
|
|
@@ -811,10 +813,15 @@ export class MailboxManagementService {
|
|
|
811
813
|
* target is written, which is how the client tells a failed delete from a
|
|
812
814
|
* failed rename.
|
|
813
815
|
*/
|
|
814
|
-
failDelete = async (
|
|
816
|
+
failDelete = async (
|
|
817
|
+
accountId: string,
|
|
818
|
+
mailboxId: string,
|
|
819
|
+
reason: string,
|
|
820
|
+
): Promise<void> => {
|
|
815
821
|
const failed = await this.mailboxService.transition(accountId, mailboxId, {
|
|
816
822
|
from: [MailboxSyncStatus.deleting],
|
|
817
823
|
to: MailboxSyncStatus.failed,
|
|
824
|
+
set: { syncFailureReason: reason },
|
|
818
825
|
});
|
|
819
826
|
if (!failed) throw new NotFoundError(`Mailbox not found: ${mailboxId}`);
|
|
820
827
|
this.log.info(
|
|
@@ -361,7 +361,13 @@ describe("MailboxManagementService.syncRename — rows it must not claim", () =>
|
|
|
361
361
|
]);
|
|
362
362
|
const service = new MailboxManagementService(repo);
|
|
363
363
|
|
|
364
|
-
await service.failRename(
|
|
364
|
+
await service.failRename(
|
|
365
|
+
"acc-1",
|
|
366
|
+
"mbx-parent",
|
|
367
|
+
"Work",
|
|
368
|
+
"Projects",
|
|
369
|
+
"Permission denied",
|
|
370
|
+
);
|
|
365
371
|
|
|
366
372
|
assert.equal(rowOf("mbx-parent")?.syncStatus, MailboxSyncStatus.failed);
|
|
367
373
|
assert.equal(rowOf("mbx-other")?.syncStatus, MailboxSyncStatus.pending);
|
|
@@ -572,7 +578,13 @@ describe("MailboxManagementService.failRename", () => {
|
|
|
572
578
|
]);
|
|
573
579
|
const service = new MailboxManagementService(repo);
|
|
574
580
|
|
|
575
|
-
await service.failRename(
|
|
581
|
+
await service.failRename(
|
|
582
|
+
"acc-1",
|
|
583
|
+
"mbx-parent",
|
|
584
|
+
"Work",
|
|
585
|
+
"Projects",
|
|
586
|
+
"Permission denied",
|
|
587
|
+
);
|
|
576
588
|
|
|
577
589
|
for (const [id, path, target] of [
|
|
578
590
|
["mbx-parent", "Work", "Projects"],
|
|
@@ -593,7 +605,13 @@ describe("MailboxManagementService.failRename", () => {
|
|
|
593
605
|
const service = new MailboxManagementService(repo);
|
|
594
606
|
|
|
595
607
|
await assert.rejects(
|
|
596
|
-
service.failRename(
|
|
608
|
+
service.failRename(
|
|
609
|
+
"acc-1",
|
|
610
|
+
"mbx-parent",
|
|
611
|
+
"Work",
|
|
612
|
+
"Projects",
|
|
613
|
+
"Permission denied",
|
|
614
|
+
),
|
|
597
615
|
(error: unknown) => (error as Error).name === "NotFoundError",
|
|
598
616
|
);
|
|
599
617
|
});
|
|
@@ -606,7 +624,13 @@ describe("MailboxManagementService.failRename", () => {
|
|
|
606
624
|
const service = new MailboxManagementService(repo);
|
|
607
625
|
|
|
608
626
|
await assert.doesNotReject(
|
|
609
|
-
service.failRename(
|
|
627
|
+
service.failRename(
|
|
628
|
+
"acc-1",
|
|
629
|
+
"mbx-parent",
|
|
630
|
+
"Work",
|
|
631
|
+
"Projects",
|
|
632
|
+
"Permission denied",
|
|
633
|
+
),
|
|
610
634
|
);
|
|
611
635
|
});
|
|
612
636
|
|
|
@@ -627,7 +651,13 @@ describe("MailboxManagementService.failRename", () => {
|
|
|
627
651
|
/not ready/,
|
|
628
652
|
);
|
|
629
653
|
|
|
630
|
-
await service.failRename(
|
|
654
|
+
await service.failRename(
|
|
655
|
+
"acc-1",
|
|
656
|
+
"mbx-parent",
|
|
657
|
+
"Work",
|
|
658
|
+
"Projects",
|
|
659
|
+
"Permission denied",
|
|
660
|
+
);
|
|
631
661
|
assert.equal(rowOf("mbx-parent")?.syncStatus, MailboxSyncStatus.failed);
|
|
632
662
|
assert.equal(rowOf("mbx-parent")?.fullPath, "Work");
|
|
633
663
|
});
|
package/src/mailbox-upstream.ts
CHANGED
|
@@ -36,6 +36,18 @@ export const isMailboxPresentUpstream = (error: unknown): boolean => {
|
|
|
36
36
|
return /already exists/i.test(saidByServer(error));
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
const PERMANENT_REFUSALS = new Set(["NOPERM", "CANNOT"]);
|
|
40
|
+
|
|
41
|
+
export const isMailboxRefusedUpstream = (error: unknown): boolean =>
|
|
42
|
+
error instanceof Error &&
|
|
43
|
+
PERMANENT_REFUSALS.has(stringField(error, "serverResponseCode"));
|
|
44
|
+
|
|
45
|
+
export const upstreamFailureReason = (error: unknown): string => {
|
|
46
|
+
const serverText = stringField(error, "responseText").trim();
|
|
47
|
+
if (serverText.length > 0) return serverText;
|
|
48
|
+
return error instanceof Error ? error.message : String(error);
|
|
49
|
+
};
|
|
50
|
+
|
|
39
51
|
/**
|
|
40
52
|
* Something after the server RENAME failed — the local settle, not the
|
|
41
53
|
* mutation. The rename landed, so this is never a refused rename: marking the
|