@remit/mailbox-service 0.0.81 → 0.0.82
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 +1 -1
- package/src/message-sync-repoint.test.ts +53 -1
- package/src/message-sync.ts +13 -6
package/package.json
CHANGED
|
@@ -49,6 +49,12 @@ const JUNK = mailboxAt("INBOX/Rubbish");
|
|
|
49
49
|
const TRASH = mailboxAt("Trash");
|
|
50
50
|
const ALL_MAIL = mailboxAt("[Gmail]/All Mail", ["All"]);
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* `pending` is what an ordinary inbound row carries: `upsertWithStatus` is
|
|
54
|
+
* called without a `syncStatus` and the repository defaults to it, and nothing
|
|
55
|
+
* on the sync path ever promotes it (#1096). The fixture states the reachable
|
|
56
|
+
* state, not the one the gate used to demand.
|
|
57
|
+
*/
|
|
52
58
|
const storedIn = (
|
|
53
59
|
mailbox: MailboxItem,
|
|
54
60
|
overrides: Partial<MessageItem> = {},
|
|
@@ -57,7 +63,7 @@ const storedIn = (
|
|
|
57
63
|
mailboxId: mailbox.mailboxId,
|
|
58
64
|
uid: 7,
|
|
59
65
|
status: MessageStatus.active,
|
|
60
|
-
syncStatus: MessageSyncStatus.
|
|
66
|
+
syncStatus: MessageSyncStatus.pending,
|
|
61
67
|
...overrides,
|
|
62
68
|
}) as MessageItem;
|
|
63
69
|
|
|
@@ -310,6 +316,26 @@ describe("repointsOnSighting", () => {
|
|
|
310
316
|
);
|
|
311
317
|
});
|
|
312
318
|
|
|
319
|
+
it("accepts an ordinary inbound row the sync path left pending", () => {
|
|
320
|
+
assert.equal(
|
|
321
|
+
repointsOnSighting(
|
|
322
|
+
JUNK,
|
|
323
|
+
storedIn(INBOX, { syncStatus: MessageSyncStatus.pending }),
|
|
324
|
+
),
|
|
325
|
+
true,
|
|
326
|
+
);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it("accepts a row a settled mutation marked synced", () => {
|
|
330
|
+
assert.equal(
|
|
331
|
+
repointsOnSighting(
|
|
332
|
+
JUNK,
|
|
333
|
+
storedIn(INBOX, { syncStatus: MessageSyncStatus.synced }),
|
|
334
|
+
),
|
|
335
|
+
true,
|
|
336
|
+
);
|
|
337
|
+
});
|
|
338
|
+
|
|
313
339
|
it("refuses a row whose move failed and has not been re-tried", () => {
|
|
314
340
|
assert.equal(
|
|
315
341
|
repointsOnSighting(
|
|
@@ -319,4 +345,30 @@ describe("repointsOnSighting", () => {
|
|
|
319
345
|
false,
|
|
320
346
|
);
|
|
321
347
|
});
|
|
348
|
+
|
|
349
|
+
it("refuses a row whose own move is still in flight", () => {
|
|
350
|
+
assert.equal(
|
|
351
|
+
repointsOnSighting(
|
|
352
|
+
JUNK,
|
|
353
|
+
storedIn(INBOX, {
|
|
354
|
+
status: MessageStatus.moving,
|
|
355
|
+
syncStatus: MessageSyncStatus.pending,
|
|
356
|
+
}),
|
|
357
|
+
),
|
|
358
|
+
false,
|
|
359
|
+
);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it("refuses a row whose own delete is still in flight", () => {
|
|
363
|
+
assert.equal(
|
|
364
|
+
repointsOnSighting(
|
|
365
|
+
JUNK,
|
|
366
|
+
storedIn(INBOX, {
|
|
367
|
+
status: MessageStatus.deleting,
|
|
368
|
+
syncStatus: MessageSyncStatus.pending,
|
|
369
|
+
}),
|
|
370
|
+
),
|
|
371
|
+
false,
|
|
372
|
+
);
|
|
373
|
+
});
|
|
322
374
|
});
|
package/src/message-sync.ts
CHANGED
|
@@ -145,8 +145,17 @@ export const addressSightingIn = (
|
|
|
145
145
|
* filing locations; following one would empty every other folder's listing. And
|
|
146
146
|
* a row whose own mutation has not settled is in flight, not stale
|
|
147
147
|
* (imap-mutations R1): the server's answer predates the move reader is still
|
|
148
|
-
* waiting on, so taking it would undo the optimistic write.
|
|
149
|
-
*
|
|
148
|
+
* waiting on, so taking it would undo the optimistic write. The sync path
|
|
149
|
+
* reconciles rather than waits (imap-mutations R2): it never blocks on a
|
|
150
|
+
* mutation, it re-reads the row on the next sighting after the move settles.
|
|
151
|
+
*
|
|
152
|
+
* In flight is read off `status`, never off `syncStatus` (#1096). Every
|
|
153
|
+
* outbound mutation writes `moving` or `deleting` and only settling returns the
|
|
154
|
+
* row to `active`, while an ordinary inbound row stays `pending` for its whole
|
|
155
|
+
* life because nothing on the sync path promotes it — so demanding `synced`
|
|
156
|
+
* here meant ordinary mail never re-pointed at all. `failed` is still refused:
|
|
157
|
+
* a mutation that gave up leaves it set on a row put back to `active`, and
|
|
158
|
+
* nothing routine settles that row afterwards.
|
|
150
159
|
*/
|
|
151
160
|
export const repointsOnSighting = (
|
|
152
161
|
mailbox: MailboxItem,
|
|
@@ -154,10 +163,8 @@ export const repointsOnSighting = (
|
|
|
154
163
|
): boolean => {
|
|
155
164
|
if (message.mailboxId === mailbox.mailboxId) return false;
|
|
156
165
|
if (isVirtualCopyMailbox(mailbox)) return false;
|
|
157
|
-
return
|
|
158
|
-
|
|
159
|
-
message.syncStatus === MessageSyncStatus.synced
|
|
160
|
-
);
|
|
166
|
+
if (message.status !== MessageStatus.active) return false;
|
|
167
|
+
return message.syncStatus !== MessageSyncStatus.failed;
|
|
161
168
|
};
|
|
162
169
|
|
|
163
170
|
/**
|