@remit/drizzle-service 0.0.79 → 0.0.80

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/drizzle-service",
3
- "version": "0.0.79",
3
+ "version": "0.0.80",
4
4
  "description": "Drizzle ORM service over SQLite",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -277,6 +277,17 @@ describe("DrizzleMessageRepository", () => {
277
277
  assert.equal(rows[0].processedAt, null, "event starts undrained");
278
278
  });
279
279
 
280
+ test("updateUid drops the source uid and keeps the folder Undo restores to", async () => {
281
+ // `originalUid` says the row's `uid` was recorded under
282
+ // `originalMailboxId`. The confirmation above makes that untrue, and a
283
+ // leftover that happens to equal the destination's own uid — two
284
+ // independent per-folder counters, so a routine collision — reads as an
285
+ // unsettled placement for the rest of the row's life (#1217).
286
+ const read = await messageRepo.get(MOVE_MESSAGE_ID);
287
+ assert.equal(read.originalUid, undefined);
288
+ assert.equal(read.originalMailboxId, SOURCE_MAILBOX_ID);
289
+ });
290
+
280
291
  test("updateForMove throws NotFoundError for unknown messageId", async () => {
281
292
  await assert.rejects(
282
293
  () =>
@@ -574,12 +574,20 @@ export class DrizzleMessageRepository implements IMessageRepository {
574
574
  // re-index would skip them on content hash. Enqueue a move re-index event
575
575
  // in the same transaction as the update; the search-index worker drains it
576
576
  // with force, refreshing the stored mailbox metadata.
577
+ //
578
+ // `originalUid` goes with the settle. It exists to say the row's `uid`
579
+ // was recorded under `originalMailboxId`, and that stops being true here;
580
+ // left behind it makes the settled row indistinguishable from an
581
+ // in-flight one whenever the destination's counter happens to hand back
582
+ // the source's number, which on a young account is most of them (#1217).
583
+ // `originalMailboxId` stays: Undo restores the message to it.
577
584
  const rows = await runInTransaction(this.db, async (tx) => {
578
585
  const updated = await tx
579
586
  .update(messageTable)
580
587
  .set({
581
588
  uid: newUid,
582
589
  mailboxId: newMailboxId,
590
+ originalUid: null,
583
591
  status: "active",
584
592
  syncStatus: "synced",
585
593
  updatedAt: Date.now(),