@remit/mailbox-service 0.0.106 → 0.0.108
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
|
@@ -150,6 +150,7 @@ class MemorySuggestions implements ICalendarSuggestionRepository {
|
|
|
150
150
|
suggestionId,
|
|
151
151
|
state: existing?.state ?? CalendarSuggestionState.Pending,
|
|
152
152
|
acceptedCalendarObjectId: existing?.acceptedCalendarObjectId ?? "",
|
|
153
|
+
supersededByMessageId: existing?.supersededByMessageId ?? "",
|
|
153
154
|
createdAt: existing?.createdAt ?? 1,
|
|
154
155
|
updatedAt: 1,
|
|
155
156
|
};
|
|
@@ -201,6 +202,7 @@ class MemorySuggestions implements ICalendarSuggestionRepository {
|
|
|
201
202
|
async supersedeIfPending(
|
|
202
203
|
_accountConfigId: string,
|
|
203
204
|
suggestionId: string,
|
|
205
|
+
supersededByMessageId: string,
|
|
204
206
|
): Promise<CalendarSuggestionItem | null> {
|
|
205
207
|
const row = this.rows.get(suggestionId);
|
|
206
208
|
if (!row || row.state !== CalendarSuggestionState.Pending) return null;
|
|
@@ -208,10 +210,23 @@ class MemorySuggestions implements ICalendarSuggestionRepository {
|
|
|
208
210
|
...row,
|
|
209
211
|
state: CalendarSuggestionState.Superseded,
|
|
210
212
|
acceptedCalendarObjectId: "",
|
|
213
|
+
supersededByMessageId,
|
|
211
214
|
};
|
|
212
215
|
this.rows.set(suggestionId, retired);
|
|
213
216
|
return retired;
|
|
214
217
|
}
|
|
218
|
+
|
|
219
|
+
async repointSuperseded(
|
|
220
|
+
_accountConfigId: string,
|
|
221
|
+
suggestionId: string,
|
|
222
|
+
supersededByMessageId: string,
|
|
223
|
+
): Promise<CalendarSuggestionItem | null> {
|
|
224
|
+
const row = this.rows.get(suggestionId);
|
|
225
|
+
if (!row || row.state !== CalendarSuggestionState.Superseded) return null;
|
|
226
|
+
const repointed = { ...row, supersededByMessageId };
|
|
227
|
+
this.rows.set(suggestionId, repointed);
|
|
228
|
+
return repointed;
|
|
229
|
+
}
|
|
215
230
|
}
|
|
216
231
|
|
|
217
232
|
interface Harness {
|
|
@@ -70,6 +70,14 @@ describe("loadOutboxAttachmentContents", () => {
|
|
|
70
70
|
);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
+
it("gives each file the content-id its reservation handed out", async () => {
|
|
74
|
+
const deps = await setup([row("shot")], ["shot"]);
|
|
75
|
+
|
|
76
|
+
const [content] = await loadOutboxAttachmentContents(deps, OWNER, NOW);
|
|
77
|
+
|
|
78
|
+
assert.equal(content.cid, "shot@remit");
|
|
79
|
+
});
|
|
80
|
+
|
|
73
81
|
it("leaves out a reservation that lapsed without its bytes", async () => {
|
|
74
82
|
const deps = await setup(
|
|
75
83
|
[
|
|
@@ -6,8 +6,12 @@ export interface OutboxAttachmentContent {
|
|
|
6
6
|
filename: string;
|
|
7
7
|
contentType: string;
|
|
8
8
|
content: Buffer;
|
|
9
|
+
cid: string;
|
|
9
10
|
}
|
|
10
11
|
|
|
12
|
+
export const outboxAttachmentContentId = (outboxAttachmentId: string): string =>
|
|
13
|
+
`${outboxAttachmentId}@remit`;
|
|
14
|
+
|
|
11
15
|
/**
|
|
12
16
|
* A file on a message that cannot be put into it. Carries the file's name so
|
|
13
17
|
* whoever settles the message can tell the sender which file to fix.
|
|
@@ -93,6 +97,7 @@ export const loadOutboxAttachmentContents = async (
|
|
|
93
97
|
filename: item.filename,
|
|
94
98
|
contentType: item.contentType,
|
|
95
99
|
content,
|
|
100
|
+
cid: outboxAttachmentContentId(item.outboxAttachmentId),
|
|
96
101
|
};
|
|
97
102
|
}),
|
|
98
103
|
);
|
|
@@ -224,6 +224,23 @@ describe("reserving room on a draft", () => {
|
|
|
224
224
|
assert.ok(row?.storageKey.endsWith(result.reservation.outboxAttachmentId));
|
|
225
225
|
});
|
|
226
226
|
|
|
227
|
+
it("names the content-id a body can refer to the file by", async () => {
|
|
228
|
+
const { service } = build();
|
|
229
|
+
|
|
230
|
+
const result = await mint(service, {
|
|
231
|
+
filename: "shot.png",
|
|
232
|
+
contentType: "image/png",
|
|
233
|
+
sizeBytes: 64,
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
assert.equal(result.outcome, "Minted");
|
|
237
|
+
if (result.outcome !== "Minted") return;
|
|
238
|
+
assert.equal(
|
|
239
|
+
result.reservation.contentId,
|
|
240
|
+
`${result.reservation.outboxAttachmentId}@remit`,
|
|
241
|
+
);
|
|
242
|
+
});
|
|
243
|
+
|
|
227
244
|
it("refuses a declared size over the cap", async () => {
|
|
228
245
|
const { service } = build();
|
|
229
246
|
|
package/src/outbox-attachment.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import {
|
|
17
17
|
loadOutboxAttachmentContents,
|
|
18
18
|
type OutboxAttachmentContent,
|
|
19
|
+
outboxAttachmentContentId,
|
|
19
20
|
} from "./outbox-attachment-content.js";
|
|
20
21
|
import {
|
|
21
22
|
normalizeAttachmentContentType,
|
|
@@ -45,6 +46,7 @@ export interface OutboxAttachmentReservation {
|
|
|
45
46
|
filename: string;
|
|
46
47
|
contentType: string;
|
|
47
48
|
sizeBytes: number;
|
|
49
|
+
contentId: string;
|
|
48
50
|
uploadUrl: string;
|
|
49
51
|
uploadExpiresAt: number;
|
|
50
52
|
}
|
|
@@ -271,6 +273,7 @@ export class OutboxAttachmentService {
|
|
|
271
273
|
filename: reserved.item.filename,
|
|
272
274
|
contentType: reserved.item.contentType,
|
|
273
275
|
sizeBytes: reserved.item.sizeBytes,
|
|
276
|
+
contentId: outboxAttachmentContentId(reserved.item.outboxAttachmentId),
|
|
274
277
|
uploadUrl: target.uploadUrl,
|
|
275
278
|
uploadExpiresAt: reservationExpiresAt,
|
|
276
279
|
},
|