Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 40 additions & 28 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion e2e/native-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ describe("native MailboxStore over the principal mailbox tables", () => {
});
const msg = reopened.find(uid);
expect(
Math.abs(msg!.envelope.date.getTime() - writeInstant.getTime()),
Math.abs(
(msg!.envelope.date ?? new Date()).getTime() - writeInstant.getTime(),
),
).toBeLessThan(1000);
});
});
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@corbits/mailbox",
"version": "0.2.0",
"version": "0.2.1",
"description": "A native Interchange mailbox for human principals, mountable onto any Interchange host. Requires @intx 0.4.0 or newer.",
"keywords": [
"corbits",
Expand Down Expand Up @@ -56,12 +56,12 @@
"devDependencies": {
"@corbits/mailbox-0.1.0": "npm:@corbits/mailbox@0.1.0",
"@hono/standard-validator": "0.2.3",
"@intx/db": "0.4.0",
"@intx/hub-api": "0.4.0",
"@intx/log": "0.4.0",
"@intx/mailbox": "0.4.0",
"@intx/mime": "0.4.0",
"@intx/types": "0.4.0",
"@intx/db": "0.5.0",
"@intx/hub-api": "0.5.0",
"@intx/log": "0.5.0",
"@intx/mailbox": "0.5.0",
"@intx/mime": "0.5.0",
"@intx/types": "0.5.0",
"@standard-community/standard-json": "0.3.5",
"@standard-community/standard-openapi": "0.2.9",
"@types/bun": "1.1.14",
Expand All @@ -77,12 +77,12 @@
"typescript": "5.7.2"
},
"peerDependencies": {
"@intx/db": "^0.4.0",
"@intx/hub-api": "^0.4.0",
"@intx/log": "^0.4.0",
"@intx/mailbox": "^0.4.0",
"@intx/mime": "^0.4.0",
"@intx/types": "^0.4.0",
"@intx/db": "^0.5.0",
"@intx/hub-api": "^0.5.0",
"@intx/log": "^0.5.0",
"@intx/mailbox": "^0.5.0",
"@intx/mime": "^0.5.0",
"@intx/types": "^0.5.0",
"drizzle-orm": "^0.45.2",
"hono": "^4.12.0",
"hono-openapi": "^1.3.1",
Expand Down
8 changes: 4 additions & 4 deletions src/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ function enrichThread(
flags: [...message.flags],
envelope: {
messageId: message.envelope.messageId,
from: message.envelope.from,
from: message.envelope.from ?? "",
to: message.envelope.to,
subject: message.envelope.subject,
date: new Date(message.envelope.date).toISOString(),
date: new Date(message.envelope.date ?? new Date()).toISOString(),
inReplyTo: message.envelope.inReplyTo,
references: message.envelope.references,
},
Expand Down Expand Up @@ -344,10 +344,10 @@ export function createMailboxRoutes(
flags: [...message.flags],
envelope: {
messageId: message.envelope.messageId,
from: message.envelope.from,
from: message.envelope.from ?? "",
to: message.envelope.to,
subject: message.envelope.subject,
date: new Date(message.envelope.date).toISOString(),
date: new Date(message.envelope.date ?? new Date()).toISOString(),
inReplyTo: message.envelope.inReplyTo,
references: message.envelope.references,
},
Expand Down
6 changes: 3 additions & 3 deletions src/native-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function withoutNul(value: string): string {
function cleanEnvelope(envelope: StoredEnvelope): StoredEnvelope {
return {
messageId: withoutNul(envelope.messageId),
from: withoutNul(envelope.from),
from: withoutNul(envelope.from ?? ""),
to: envelope.to.map(withoutNul),
subject: withoutNul(envelope.subject),
date: envelope.date,
Expand Down Expand Up @@ -264,7 +264,7 @@ export async function openNativeMailboxStore(
${envelope.from}, ${envelope.messageId || null}, ${envelope.inReplyTo ?? null},
${envelope.references.length > 0 ? JSON.stringify(envelope.references) : null},
${envelope.to.length > 0 ? JSON.stringify(envelope.to) : null},
${envelope.date.toISOString()}, ${folder}, ${uid}, ${modseq}, ${pgTextArrayLiteral(flags)}::text[]
${(envelope.date ?? new Date()).toISOString()}, ${folder}, ${uid}, ${modseq}, ${pgTextArrayLiteral(flags)}::text[]
)
`);
await tx.execute(sql`
Expand Down Expand Up @@ -328,7 +328,7 @@ export async function openNativeMailboxStore(
${withoutNul(sender)}, ${envelope.messageId || null}, ${envelope.inReplyTo ?? null},
${envelope.references.length > 0 ? JSON.stringify(envelope.references) : null},
${envelope.to.length > 0 ? JSON.stringify(envelope.to) : null},
${envelope.date.toISOString()}, ${folder}, ${uid}, ${modseq}, ${pgTextArrayLiteral(flags)}::text[]
${(envelope.date ?? new Date()).toISOString()}, ${folder}, ${uid}, ${modseq}, ${pgTextArrayLiteral(flags)}::text[]
)
ON CONFLICT ("tenant_id", "principal_id", "folder", "message_id", "sender_address")
WHERE "message_id" IS NOT NULL
Expand Down
Loading