@remit/drizzle-service 0.0.23 → 0.0.25
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
|
: {}),
|
|
@@ -194,6 +194,7 @@ CREATE TABLE IF NOT EXISTS message (
|
|
|
194
194
|
has_list_unsubscribe BOOLEAN NOT NULL DEFAULT false,
|
|
195
195
|
moved_by_remit BOOLEAN NOT NULL DEFAULT false,
|
|
196
196
|
placement_verdict JSONB,
|
|
197
|
+
filter_move JSONB,
|
|
197
198
|
created_at BIGINT NOT NULL,
|
|
198
199
|
updated_at BIGINT NOT NULL
|
|
199
200
|
);
|