@remit/drizzle-service 0.0.24 → 0.0.26
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
|
@@ -74,6 +74,52 @@ describe("DrizzleMessageRepository (sqlite)", () => {
|
|
|
74
74
|
assert.deepEqual(item.authenticity, { spf: "pass" });
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
+
test("filterMove and placementVerdict JSONB columns round-trip through create and update", async () => {
|
|
78
|
+
// The auto-moved badge for a standing-filter move depends on this
|
|
79
|
+
// round-trip: body-sync writes `filterMove`, and both read paths project it
|
|
80
|
+
// back through `toMessageItem` for `deriveAutoMoved` (issue #223).
|
|
81
|
+
const AUTO_MOVED_ID = "00000000-0000-0000-2222-000000000003";
|
|
82
|
+
const filterMove = {
|
|
83
|
+
filterId: "00000000-0000-0000-2222-0000000000f1",
|
|
84
|
+
sourceMailboxId: "00000000-0000-0000-2222-0000000000f2",
|
|
85
|
+
destinationMailboxId: "00000000-0000-0000-2222-0000000000f3",
|
|
86
|
+
decidedAt: NOW,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const created = await repo.create({
|
|
90
|
+
...BASE_INPUT,
|
|
91
|
+
messageId: AUTO_MOVED_ID,
|
|
92
|
+
envelopeId: deriveEnvelopeId(AUTO_MOVED_ID),
|
|
93
|
+
rootBodyPartId: deriveRootBodyPartId(AUTO_MOVED_ID),
|
|
94
|
+
movedByRemit: true,
|
|
95
|
+
filterMove: filterMove as unknown as never,
|
|
96
|
+
});
|
|
97
|
+
assert.deepEqual(created.filterMove, filterMove);
|
|
98
|
+
|
|
99
|
+
const afterCreate = await repo.get(AUTO_MOVED_ID);
|
|
100
|
+
assert.equal(afterCreate.movedByRemit, true);
|
|
101
|
+
assert.deepEqual(afterCreate.filterMove, filterMove);
|
|
102
|
+
|
|
103
|
+
// A later placement update must not disturb the marker, and a new marker
|
|
104
|
+
// must overwrite the old one — the same JSONB-set path body-sync uses.
|
|
105
|
+
const nextFilterMove = { ...filterMove, destinationMailboxId: "mb-other" };
|
|
106
|
+
await repo.update(AUTO_MOVED_ID, {
|
|
107
|
+
filterMove: nextFilterMove as unknown as never,
|
|
108
|
+
placementVerdict: {
|
|
109
|
+
action: "MoveToInbox",
|
|
110
|
+
confidence: "Confident",
|
|
111
|
+
fromPlacement: "junk",
|
|
112
|
+
reasons: ["provider=spam"],
|
|
113
|
+
dryRun: false,
|
|
114
|
+
decidedAt: NOW,
|
|
115
|
+
} as unknown as never,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const afterUpdate = await repo.get(AUTO_MOVED_ID);
|
|
119
|
+
assert.deepEqual(afterUpdate.filterMove, nextFilterMove);
|
|
120
|
+
assert.equal(afterUpdate.placementVerdict?.action, "MoveToInbox");
|
|
121
|
+
});
|
|
122
|
+
|
|
77
123
|
test("duplicate messageId throws CreateFailedConflictError and rolls back the outbox row", async () => {
|
|
78
124
|
const before = await db
|
|
79
125
|
.select()
|
package/src/repos/message.ts
CHANGED
|
@@ -88,6 +88,9 @@ function toMessageItem(row: typeof messageTable.$inferSelect): MessageItem {
|
|
|
88
88
|
row.placementVerdict as MessageItem["placementVerdict"],
|
|
89
89
|
}
|
|
90
90
|
: {}),
|
|
91
|
+
...(row.filterMove !== null
|
|
92
|
+
? { filterMove: row.filterMove as MessageItem["filterMove"] }
|
|
93
|
+
: {}),
|
|
91
94
|
};
|
|
92
95
|
}
|
|
93
96
|
|
|
@@ -188,6 +191,7 @@ export class DrizzleMessageRepository implements IMessageRepository {
|
|
|
188
191
|
authResult: input.authResult ?? null,
|
|
189
192
|
providerSpam: input.providerSpam ?? null,
|
|
190
193
|
placementVerdict: input.placementVerdict ?? null,
|
|
194
|
+
filterMove: input.filterMove ?? null,
|
|
191
195
|
createdAt: now,
|
|
192
196
|
updatedAt: now,
|
|
193
197
|
};
|
|
@@ -374,6 +378,9 @@ export class DrizzleMessageRepository implements IMessageRepository {
|
|
|
374
378
|
...(input.placementVerdict !== undefined
|
|
375
379
|
? { placementVerdict: input.placementVerdict }
|
|
376
380
|
: {}),
|
|
381
|
+
...(input.filterMove !== undefined
|
|
382
|
+
? { filterMove: input.filterMove }
|
|
383
|
+
: {}),
|
|
377
384
|
...(input.messageIdHeader !== undefined
|
|
378
385
|
? { messageIdHeader: input.messageIdHeader }
|
|
379
386
|
: {}),
|
|
@@ -122,6 +122,7 @@ function toItem(row: Row): ThreadMessageItem {
|
|
|
122
122
|
...(row.fromName !== null ? { fromName: row.fromName } : {}),
|
|
123
123
|
...(row.subject !== null ? { subject: row.subject } : {}),
|
|
124
124
|
...(row.snippet !== null ? { snippet: row.snippet } : {}),
|
|
125
|
+
...(row.listId !== null ? { listId: row.listId } : {}),
|
|
125
126
|
};
|
|
126
127
|
}
|
|
127
128
|
|
|
@@ -237,6 +238,7 @@ export class DrizzleThreadMessageRepository
|
|
|
237
238
|
fromName: input.fromName ?? null,
|
|
238
239
|
subject: input.subject ?? null,
|
|
239
240
|
snippet: input.snippet ?? null,
|
|
241
|
+
listId: input.listId ?? null,
|
|
240
242
|
createdAt: now,
|
|
241
243
|
updatedAt: now,
|
|
242
244
|
};
|
|
@@ -321,6 +323,7 @@ export class DrizzleThreadMessageRepository
|
|
|
321
323
|
if (input.star !== undefined) set.star = input.star;
|
|
322
324
|
if (input.category !== undefined) set.category = input.category;
|
|
323
325
|
if (input.subject !== undefined) set.subject = input.subject;
|
|
326
|
+
if (input.listId !== undefined) set.listId = input.listId;
|
|
324
327
|
if (input.fromEmail !== undefined) set.fromEmail = input.fromEmail;
|
|
325
328
|
if (input.fromName !== undefined) set.fromName = input.fromName;
|
|
326
329
|
if (input.snippet !== undefined) set.snippet = input.snippet;
|