inboxer 0.4.8 → 0.4.9
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/dist/core/mail.d.ts +10 -0
- package/dist/core/mail.js +39 -8
- package/dist/core/threads.d.ts +1 -1
- package/dist/core/threads.js +2 -2
- package/dist/ui/routes.js +15 -13
- package/dist/ui/static/style.css +8 -5
- package/dist/ui/views.d.ts +13 -7
- package/dist/ui/views.js +28 -15
- package/package.json +1 -1
package/dist/core/mail.d.ts
CHANGED
|
@@ -74,6 +74,7 @@ export declare class Mail {
|
|
|
74
74
|
readonly provider: MailProvider;
|
|
75
75
|
readonly cfg: InboxerConfig;
|
|
76
76
|
private readonly ownAddresses;
|
|
77
|
+
private readonly domains;
|
|
77
78
|
private readonly timers;
|
|
78
79
|
private readonly files;
|
|
79
80
|
constructor(store: Store, provider: MailProvider, cfg: InboxerConfig);
|
|
@@ -82,11 +83,20 @@ export declare class Mail {
|
|
|
82
83
|
address: string;
|
|
83
84
|
name: string;
|
|
84
85
|
}[];
|
|
86
|
+
/** A configured mailbox address or any other address on its domains, such as one the catch-all received. */
|
|
87
|
+
isOwn(address: string): boolean;
|
|
88
|
+
/** The first address on our domains that is not a configured mailbox: the one a catch-all message was written to. */
|
|
89
|
+
private catchAllAddress;
|
|
90
|
+
/** The account a thread belongs to: its mailbox or, in the catch-all, the address it was written to. */
|
|
91
|
+
accountOf(thread: Thread): string;
|
|
92
|
+
/** Mailboxes in scope, with the catch-all split into the addresses it has received mail for. */
|
|
93
|
+
listAccounts(scope: Scope): Promise<string[]>;
|
|
85
94
|
requireMessage(id: string, scope: Scope): Promise<Message>;
|
|
86
95
|
requireThread(id: string, scope: Scope): Promise<Thread>;
|
|
87
96
|
/** Scoped actors only reach contacts that take part in one of their threads. */
|
|
88
97
|
private requireContactAccess;
|
|
89
98
|
private mailboxFor;
|
|
99
|
+
/** Who sends for `id`; the catch-all answers as `address`, with the name and signature of a mailbox on that domain. */
|
|
90
100
|
private sendingMailbox;
|
|
91
101
|
/**
|
|
92
102
|
* Stores an inbound message once per provider id and returns its id. Attachments are copied to
|
package/dist/core/mail.js
CHANGED
|
@@ -28,6 +28,7 @@ export class Mail {
|
|
|
28
28
|
provider;
|
|
29
29
|
cfg;
|
|
30
30
|
ownAddresses;
|
|
31
|
+
domains;
|
|
31
32
|
timers = new Map();
|
|
32
33
|
files;
|
|
33
34
|
constructor(store, provider, cfg) {
|
|
@@ -35,6 +36,7 @@ export class Mail {
|
|
|
35
36
|
this.provider = provider;
|
|
36
37
|
this.cfg = cfg;
|
|
37
38
|
this.ownAddresses = new Set(Object.values(cfg.mailboxes).map(m => bareAddress(m.address)));
|
|
39
|
+
this.domains = new Set(Object.values(cfg.mailboxes).map(m => domainOf(m.address)));
|
|
38
40
|
this.files = new AttachmentFiles(cfg.dataDir);
|
|
39
41
|
}
|
|
40
42
|
listMailboxes(scope) {
|
|
@@ -43,6 +45,27 @@ export class Mail {
|
|
|
43
45
|
{ id: CATCHALL, address: "*", name: "Catch-all" },
|
|
44
46
|
].filter(m => reaches(scope, m.id));
|
|
45
47
|
}
|
|
48
|
+
/** A configured mailbox address or any other address on its domains, such as one the catch-all received. */
|
|
49
|
+
isOwn(address) {
|
|
50
|
+
const bare = bareAddress(address);
|
|
51
|
+
return this.ownAddresses.has(bare) || this.domains.has(domainOf(bare));
|
|
52
|
+
}
|
|
53
|
+
/** The first address on our domains that is not a configured mailbox: the one a catch-all message was written to. */
|
|
54
|
+
catchAllAddress(addresses) {
|
|
55
|
+
return addresses.map(bareAddress).find(a => this.domains.has(domainOf(a)) && !this.ownAddresses.has(a)) ?? null;
|
|
56
|
+
}
|
|
57
|
+
/** The account a thread belongs to: its mailbox or, in the catch-all, the address it was written to. */
|
|
58
|
+
accountOf(thread) {
|
|
59
|
+
return thread.mailbox === CATCHALL ? this.catchAllAddress(thread.participants) ?? CATCHALL : thread.mailbox;
|
|
60
|
+
}
|
|
61
|
+
/** Mailboxes in scope, with the catch-all split into the addresses it has received mail for. */
|
|
62
|
+
async listAccounts(scope) {
|
|
63
|
+
const mailboxes = this.listMailboxes(scope).map(m => m.id).filter(id => id !== CATCHALL);
|
|
64
|
+
if (!reaches(scope, CATCHALL))
|
|
65
|
+
return mailboxes;
|
|
66
|
+
const caught = (await this.store.allThreads()).filter(t => t.mailbox === CATCHALL).map(t => this.accountOf(t));
|
|
67
|
+
return [...mailboxes, ...[...new Set(caught)].sort()];
|
|
68
|
+
}
|
|
46
69
|
// Out of scope reads as missing, so a scoped token cannot probe other mailboxes.
|
|
47
70
|
async requireMessage(id, scope) {
|
|
48
71
|
const message = await this.store.requireMessage(id);
|
|
@@ -73,7 +96,11 @@ export class Mail {
|
|
|
73
96
|
}
|
|
74
97
|
return CATCHALL;
|
|
75
98
|
}
|
|
76
|
-
|
|
99
|
+
/** Who sends for `id`; the catch-all answers as `address`, with the name and signature of a mailbox on that domain. */
|
|
100
|
+
sendingMailbox(id, address) {
|
|
101
|
+
const peer = id === CATCHALL && address ? Object.values(this.cfg.mailboxes).find(m => domainOf(m.address) === domainOf(address)) : undefined;
|
|
102
|
+
if (peer && address)
|
|
103
|
+
return { name: peer.name, address: bareAddress(address), signatureText: peer.signatureText, signatureHtml: peer.signatureHtml };
|
|
77
104
|
const mailbox = this.cfg.mailboxes[id];
|
|
78
105
|
if (!mailbox)
|
|
79
106
|
throw new InvalidRequestError(`Mailbox "${id}" cannot send (configured: ${Object.keys(this.cfg.mailboxes).join(", ")})`);
|
|
@@ -110,7 +137,7 @@ export class Mail {
|
|
|
110
137
|
subject: inbound.subject,
|
|
111
138
|
participants,
|
|
112
139
|
at: inbound.receivedAt,
|
|
113
|
-
}, this.
|
|
140
|
+
}, address => this.isOwn(address), this.cfg.threadWindowDays);
|
|
114
141
|
const message = {
|
|
115
142
|
id: nid(),
|
|
116
143
|
provider: this.provider.name,
|
|
@@ -195,7 +222,7 @@ export class Mail {
|
|
|
195
222
|
return false;
|
|
196
223
|
if (byMeta && !byMeta(t.id, t.participants))
|
|
197
224
|
return false;
|
|
198
|
-
if (input.mailbox && t.mailbox !== input.mailbox)
|
|
225
|
+
if (input.mailbox && t.mailbox !== input.mailbox && this.accountOf(t) !== input.mailbox)
|
|
199
226
|
return false;
|
|
200
227
|
if (input.label && !t.labels[input.label])
|
|
201
228
|
return false;
|
|
@@ -242,7 +269,7 @@ export class Mail {
|
|
|
242
269
|
}
|
|
243
270
|
/** The thread's own context and the contacts of its external participants that have one. */
|
|
244
271
|
async contextOf(thread) {
|
|
245
|
-
const external = thread.participants.filter(p => !this.
|
|
272
|
+
const external = thread.participants.filter(p => !this.isOwn(p));
|
|
246
273
|
const contacts = (await Promise.all(external.map(p => this.store.getContact(p)))).filter((c) => !!c);
|
|
247
274
|
return { context: await this.store.getThreadContext(thread.id), contacts };
|
|
248
275
|
}
|
|
@@ -340,13 +367,16 @@ export class Mail {
|
|
|
340
367
|
replyDefaults(original, given, replyAll) {
|
|
341
368
|
const mailbox = given.mailbox ?? original.mailbox;
|
|
342
369
|
const to = given.to ?? (original.direction === "in" ? (original.reply_to.length ? original.reply_to : [original.from]) : original.to);
|
|
343
|
-
const
|
|
370
|
+
const caught = mailbox === CATCHALL ? this.catchAllAddress(original.direction === "out" ? [original.from] : [...original.to, ...original.cc]) : null;
|
|
371
|
+
const sender = this.sendingMailbox(mailbox, caught);
|
|
372
|
+
const already = new Set([bareAddress(sender.address), ...to.map(bareAddress)]);
|
|
344
373
|
const cc = replyAll ? [...original.to, ...original.cc].filter(a => !already.has(bareAddress(a))) : [];
|
|
345
|
-
return { mailbox, to, cc, subject: replySubject(original.subject) };
|
|
374
|
+
return { mailbox, sender, to, cc, subject: replySubject(original.subject) };
|
|
346
375
|
}
|
|
347
376
|
async createDraftUnlocked(input, actor) {
|
|
348
377
|
const now = new Date().toISOString();
|
|
349
378
|
let mailbox;
|
|
379
|
+
let sender;
|
|
350
380
|
let to;
|
|
351
381
|
let cc = input.cc ?? [];
|
|
352
382
|
let subject;
|
|
@@ -357,6 +387,7 @@ export class Mail {
|
|
|
357
387
|
const original = await this.requireMessage(input.replyToId, actor.scope);
|
|
358
388
|
const defaults = this.replyDefaults(original, input, !!input.replyAll && !input.cc);
|
|
359
389
|
mailbox = defaults.mailbox;
|
|
390
|
+
sender = defaults.sender;
|
|
360
391
|
to = defaults.to;
|
|
361
392
|
if (!input.cc)
|
|
362
393
|
cc = defaults.cc;
|
|
@@ -373,11 +404,11 @@ export class Mail {
|
|
|
373
404
|
if (input.subject === undefined)
|
|
374
405
|
throw new InvalidRequestError("subject is required when not replying");
|
|
375
406
|
mailbox = input.mailbox;
|
|
407
|
+
sender = this.sendingMailbox(mailbox, null);
|
|
376
408
|
to = input.to;
|
|
377
409
|
subject = input.subject;
|
|
378
410
|
threadId = nid();
|
|
379
411
|
}
|
|
380
|
-
const sender = this.sendingMailbox(mailbox);
|
|
381
412
|
if (!reaches(actor.scope, mailbox))
|
|
382
413
|
throw new InvalidRequestError(`Mailbox "${mailbox}" is not available to ${actor.name}`);
|
|
383
414
|
const draft = {
|
|
@@ -573,7 +604,7 @@ export class Mail {
|
|
|
573
604
|
*/
|
|
574
605
|
async sendDraftUnlocked(id, actor) {
|
|
575
606
|
const draft = await this.requireDraft(id, actor.scope);
|
|
576
|
-
const sender = this.sendingMailbox(draft.mailbox);
|
|
607
|
+
const sender = this.sendingMailbox(draft.mailbox, draft.from);
|
|
577
608
|
if (!draft.message_id) {
|
|
578
609
|
draft.message_id = `<${randomUUID()}@${domainOf(sender.address)}>`;
|
|
579
610
|
await this.store.putMessage(draft);
|
package/dist/core/threads.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface ThreadLookup {
|
|
|
15
15
|
* 2. Same normalized subject and a shared external participant, within the window.
|
|
16
16
|
* 3. A new thread.
|
|
17
17
|
*/
|
|
18
|
-
export declare function resolveThreadId(store: Store, lookup: ThreadLookup,
|
|
18
|
+
export declare function resolveThreadId(store: Store, lookup: ThreadLookup, isOwn: (address: string) => boolean, windowDays: number): Promise<string>;
|
|
19
19
|
export declare function threadMessages(store: Store, thread: Thread): Promise<Message[]>;
|
|
20
20
|
/** Recomputes the thread summary, adding `newMessageId` when given. A thread left with only discarded drafts is removed. */
|
|
21
21
|
export declare function refreshThread(store: Store, threadId: string, newMessageId?: string): Promise<Thread | null>;
|
package/dist/core/threads.js
CHANGED
|
@@ -13,7 +13,7 @@ export function participantsOf(message) {
|
|
|
13
13
|
* 2. Same normalized subject and a shared external participant, within the window.
|
|
14
14
|
* 3. A new thread.
|
|
15
15
|
*/
|
|
16
|
-
export async function resolveThreadId(store, lookup,
|
|
16
|
+
export async function resolveThreadId(store, lookup, isOwn, windowDays) {
|
|
17
17
|
for (const ref of [lookup.inReplyTo, ...[...lookup.references].reverse()]) {
|
|
18
18
|
if (!ref)
|
|
19
19
|
continue;
|
|
@@ -23,7 +23,7 @@ export async function resolveThreadId(store, lookup, ownAddresses, windowDays) {
|
|
|
23
23
|
return message.thread_id;
|
|
24
24
|
}
|
|
25
25
|
const subject = normalizeSubject(lookup.subject);
|
|
26
|
-
const external = new Set(lookup.participants.filter(p => !
|
|
26
|
+
const external = new Set(lookup.participants.filter(p => !isOwn(p)));
|
|
27
27
|
if (subject && external.size) {
|
|
28
28
|
const since = new Date(lookup.at).getTime() - windowDays * DAY_MS;
|
|
29
29
|
const match = (await store.allThreads())
|
package/dist/ui/routes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { deleteCookie, getCookie, getSignedCookie, setCookie, setSignedCookie } from "hono/cookie";
|
|
2
|
-
import {
|
|
2
|
+
import { domainOf, splitAddresses } from "../core/address.js";
|
|
3
3
|
import { ConflictError, InvalidRequestError, toView } from "../core/mail.js";
|
|
4
4
|
import { CATCHALL } from "../types.js";
|
|
5
5
|
import { S } from "./strings.js";
|
|
@@ -23,12 +23,12 @@ function uiActor(session) {
|
|
|
23
23
|
export function registerUi(app, mail, access, cfg) {
|
|
24
24
|
const secret = cfg.ui.cookieSecret;
|
|
25
25
|
const cookieOptions = { httpOnly: true, secure: true, sameSite: "Lax", path: "/", maxAge: COOKIE_MAX_AGE };
|
|
26
|
-
const own =
|
|
27
|
-
/** Recipients that are our own
|
|
26
|
+
const own = (address) => mail.isOwn(address);
|
|
27
|
+
/** Recipients that are our own addresses are implied by the mailbox badge. */
|
|
28
28
|
const shown = (m) => ({
|
|
29
29
|
...m,
|
|
30
|
-
to: m.to.filter(a => !own
|
|
31
|
-
cc: m.cc.filter(a => !own
|
|
30
|
+
to: m.to.filter(a => !own(a)),
|
|
31
|
+
cc: m.cc.filter(a => !own(a)),
|
|
32
32
|
});
|
|
33
33
|
/** Mailboxes a session can send from: every one in its scope but the catch-all. */
|
|
34
34
|
const senders = (session) => mail.listMailboxes(session.scope).filter(m => m.id !== CATCHALL);
|
|
@@ -96,8 +96,9 @@ export function registerUi(app, mail, access, cfg) {
|
|
|
96
96
|
return V.draftCard(draft);
|
|
97
97
|
};
|
|
98
98
|
app.get("/", async (c) => {
|
|
99
|
-
const
|
|
100
|
-
|
|
99
|
+
const session = c.get("session");
|
|
100
|
+
const drafts = await mail.listDrafts(undefined, session.scope);
|
|
101
|
+
return page(c, S.navDrafts, V.inboxPage(V.draftList(drafts, domainsOf(session), null), null), "drafts");
|
|
101
102
|
});
|
|
102
103
|
app.get("/drafts/:id", async (c) => {
|
|
103
104
|
const session = c.get("session");
|
|
@@ -106,7 +107,7 @@ export function registerUi(app, mail, access, cfg) {
|
|
|
106
107
|
return c.redirect(`/threads/${draft.thread_id}?status=all`, 303);
|
|
107
108
|
const { thread, view } = await threadPane(c, draft.thread_id, "/");
|
|
108
109
|
const drafts = await mail.listDrafts(undefined, session.scope);
|
|
109
|
-
return page(c, thread.subject || S.navDrafts, V.inboxPage(V.draftList(drafts, draft.id), view), "drafts", 200, true);
|
|
110
|
+
return page(c, thread.subject || S.navDrafts, V.inboxPage(V.draftList(drafts, domainsOf(session), draft.id), view), "drafts", 200, true);
|
|
110
111
|
});
|
|
111
112
|
app.get("/drafts/:id/card", async (c) => c.html(await draftView(c, c.req.param("id"))));
|
|
112
113
|
app.get("/drafts/:id/edit", async (c) => {
|
|
@@ -194,8 +195,8 @@ export function registerUi(app, mail, access, cfg) {
|
|
|
194
195
|
const session = c.get("session");
|
|
195
196
|
const filter = inboxFilter(c);
|
|
196
197
|
const threads = await mail.listThreads({ mailbox: filter.mailbox || undefined, status: filter.status, limit: 200 }, session.scope);
|
|
197
|
-
const
|
|
198
|
-
return V.threadList(threads, {
|
|
198
|
+
const accounts = await mail.listAccounts(session.scope);
|
|
199
|
+
return V.threadList(threads, { accounts, accountOf: t => mail.accountOf(t), domains: domainsOf(session), filter, own, current });
|
|
199
200
|
};
|
|
200
201
|
app.get("/inbox", async (c) => page(c, S.navInbox, V.inboxPage(await threadList(c, null), null), "inbox"));
|
|
201
202
|
/** A thread with its drafts in place; opening it marks it read. */
|
|
@@ -207,13 +208,14 @@ export function registerUi(app, mail, access, cfg) {
|
|
|
207
208
|
thread = await mail.requireThread(id, session.scope);
|
|
208
209
|
}
|
|
209
210
|
const { messages, context, contacts } = await mail.getThread(id, session.scope);
|
|
210
|
-
const people = thread.participants.filter(p => !own
|
|
211
|
+
const people = thread.participants.filter(p => !own(p));
|
|
211
212
|
const entries = await Promise.all(messages.map(async (m) => ({
|
|
212
213
|
at: m.date,
|
|
213
214
|
view: m.status === "draft" ? V.draftCard(await mail.store.requireMessage(m.id)) : V.messageBubble(shown(m), people.length > 1),
|
|
214
215
|
})));
|
|
215
|
-
const
|
|
216
|
-
|
|
216
|
+
const account = mail.accountOf(thread);
|
|
217
|
+
const reply = { allowed: account !== CATCHALL && (thread.mailbox === CATCHALL || senders(session).some(m => m.id === thread.mailbox)), replyAll: people.length > 1 };
|
|
218
|
+
return { thread, view: V.threadView(thread, entries, { context, contacts }, { back, filter: inboxFilter(c), own, account, reply }) };
|
|
217
219
|
};
|
|
218
220
|
app.get("/threads/:id", async (c) => {
|
|
219
221
|
const id = c.req.param("id");
|
package/dist/ui/static/style.css
CHANGED
|
@@ -38,7 +38,7 @@ h1 { font-size: 2rem; line-height: 1.1; letter-spacing: -0.04em; font-weight: 70
|
|
|
38
38
|
.sidebar { display: none; }
|
|
39
39
|
body.app { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
|
|
40
40
|
body.app.full { padding-bottom: 0; }
|
|
41
|
-
.page { max-width: 760px;
|
|
41
|
+
.page { max-width: 760px; padding: 24px 16px 32px; }
|
|
42
42
|
|
|
43
43
|
.tabbar {
|
|
44
44
|
position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
|
|
@@ -75,7 +75,7 @@ body.full .tabbar { display: none; }
|
|
|
75
75
|
display: flex; flex-direction: column; gap: 4px;
|
|
76
76
|
padding: 20px 14px; border-right: 1px solid var(--line);
|
|
77
77
|
}
|
|
78
|
-
.brand { font-size:
|
|
78
|
+
.brand { font-size: 21px; line-height: 1.2; font-weight: 700; letter-spacing: -0.03em; text-transform: lowercase; padding: 0 12px; }
|
|
79
79
|
.brand span { color: var(--accent); }
|
|
80
80
|
.new-mail { display: flex; align-items: center; justify-content: center; gap: 8px; height: 44px; border-radius: 12px; margin: 16px 0 14px; }
|
|
81
81
|
.side-nav { display: flex; flex-direction: column; gap: 2px; }
|
|
@@ -103,8 +103,9 @@ body.full .tabbar { display: none; }
|
|
|
103
103
|
body.context-open .split .list { display: none; }
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
.list-head { padding:
|
|
106
|
+
.list-head { padding: 20px 16px 12px; }
|
|
107
107
|
.list-head h1 { font-size: 21px; line-height: 1.2; letter-spacing: -0.02em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
108
|
+
.list-head small { font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--muted); margin-left: 4px; }
|
|
108
109
|
.filters { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
|
|
109
110
|
.chips { display: flex; flex: none; gap: 8px; }
|
|
110
111
|
.filters .select { min-width: 0; }
|
|
@@ -200,8 +201,9 @@ button.thread-title:hover { background: var(--soft); border: none; }
|
|
|
200
201
|
}
|
|
201
202
|
.composer textarea:focus { border-color: var(--focus); }
|
|
202
203
|
.composer .send { width: 44px; height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
|
|
203
|
-
.reply-all { flex-basis: 100%; display: flex; align-items: center; gap: 8px; padding: 2px
|
|
204
|
-
|
|
204
|
+
.reply-all { flex-basis: 100%; display: flex; align-items: center; gap: 8px; padding: 2px 0; font-family: var(--mono); font-size: .72rem; color: var(--muted); cursor: pointer; }
|
|
205
|
+
/* Centered over the + button below it, which is 44px wide. */
|
|
206
|
+
.reply-all input { width: 16px; height: 16px; margin: 0 0 0 14px; flex: none; accent-color: var(--accent); }
|
|
205
207
|
|
|
206
208
|
/* Context: a side panel on a wide screen, a bottom sheet on a phone */
|
|
207
209
|
.context-panel { display: none; background: var(--bg); }
|
|
@@ -394,6 +396,7 @@ textarea {
|
|
|
394
396
|
.setting label { font-weight: 500; }
|
|
395
397
|
.row.device:hover { background: none; }
|
|
396
398
|
.row.device .avatar { color: var(--muted); }
|
|
399
|
+
.row.device form { display: contents; }
|
|
397
400
|
.row.device .danger { align-self: center; padding: 0; height: auto; border: none; background: none; }
|
|
398
401
|
.row.device .danger:hover { text-decoration: underline; }
|
|
399
402
|
.setting .danger, .setting .danger:hover { padding: 0; height: auto; border: none; background: none; }
|
package/dist/ui/views.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HtmlEscapedString } from "hono/utils/html";
|
|
2
2
|
import type { MessageView } from "../core/mail.ts";
|
|
3
|
-
import type
|
|
3
|
+
import { type Contact, type Context, type Message, type Session, type Thread } from "../types.ts";
|
|
4
4
|
export type View = HtmlEscapedString;
|
|
5
5
|
export type Theme = "system" | "light" | "dark";
|
|
6
6
|
export type Page = "drafts" | "inbox" | "devices" | "settings" | null;
|
|
@@ -50,20 +50,24 @@ export declare function draftEditor(d: Message, form: DraftForm, conflict: Messa
|
|
|
50
50
|
export declare function draftFiles(d: Message, error: string | null): View;
|
|
51
51
|
export declare function draftDone(id: string, text: string): View;
|
|
52
52
|
/** Drafts waiting for review, listed like the inbox; each opens its thread. */
|
|
53
|
-
export declare function draftList(drafts: Message[], current: string | null): View;
|
|
53
|
+
export declare function draftList(drafts: Message[], domains: string[], current: string | null): View;
|
|
54
54
|
export interface InboxFilter {
|
|
55
55
|
mailbox: string;
|
|
56
56
|
status: string;
|
|
57
57
|
}
|
|
58
58
|
export declare function inboxQuery(filter: InboxFilter): string;
|
|
59
59
|
/** The thread list; on a wide screen it stays beside the open thread. */
|
|
60
|
-
export declare function threadList(threads: Thread[], opts: {
|
|
61
|
-
mailboxes: string[];
|
|
60
|
+
export declare function threadList(threads: Thread[], opts: ThreadListOptions & {
|
|
62
61
|
domains: string[];
|
|
62
|
+
}): View;
|
|
63
|
+
interface ThreadListOptions {
|
|
64
|
+
/** Mailbox ids and catch-all addresses, as filter values. */
|
|
65
|
+
accounts: string[];
|
|
66
|
+
accountOf: (t: Thread) => string;
|
|
63
67
|
filter: InboxFilter;
|
|
64
|
-
own:
|
|
68
|
+
own: (address: string) => boolean;
|
|
65
69
|
current: string | null;
|
|
66
|
-
}
|
|
70
|
+
}
|
|
67
71
|
/** The thread list and the open thread side by side; a phone shows one of the two. */
|
|
68
72
|
export declare function inboxPage(list: View, thread: View | null): View;
|
|
69
73
|
export interface ThreadEntry {
|
|
@@ -74,7 +78,8 @@ export interface ThreadEntry {
|
|
|
74
78
|
export declare function threadView(thread: Thread, entries: ThreadEntry[], ctx: ContextView, opts: {
|
|
75
79
|
back: string;
|
|
76
80
|
filter: InboxFilter;
|
|
77
|
-
own:
|
|
81
|
+
own: (address: string) => boolean;
|
|
82
|
+
account: string;
|
|
78
83
|
reply: {
|
|
79
84
|
allowed: boolean;
|
|
80
85
|
replyAll: boolean;
|
|
@@ -83,3 +88,4 @@ export declare function threadView(thread: Thread, entries: ThreadEntry[], ctx:
|
|
|
83
88
|
export declare function archiveButton(thread: Thread): View;
|
|
84
89
|
export declare function devicesPage(sessions: Session[], currentId: string): View;
|
|
85
90
|
export declare function settingsPage(theme: Theme): View;
|
|
91
|
+
export {};
|
package/dist/ui/views.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { html, raw } from "hono/html";
|
|
2
2
|
import { bareAddress } from "../core/address.js";
|
|
3
|
+
import { CATCHALL } from "../types.js";
|
|
3
4
|
import { ASSETS } from "./assets.js";
|
|
4
5
|
import { S } from "./strings.js";
|
|
5
6
|
/** Views never await, so `html` returns a plain escaped string. */
|
|
@@ -155,8 +156,12 @@ export function signIn(token, valid) {
|
|
|
155
156
|
<form method="post" action="/auth/${token}"><button class="primary">${S.signInButton}</button></form>
|
|
156
157
|
</div>`;
|
|
157
158
|
}
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
/** An account by its mailbox id, or by the local part of an address the catch-all received. */
|
|
160
|
+
function mailboxBadge(account) {
|
|
161
|
+
return h `<span class="badge mailbox">${account.includes("@") ? account.slice(0, account.lastIndexOf("@")) : account}</span>`;
|
|
162
|
+
}
|
|
163
|
+
function draftAccount(d) {
|
|
164
|
+
return d.mailbox === CATCHALL ? bareAddress(d.from) : d.mailbox;
|
|
160
165
|
}
|
|
161
166
|
const PREVIEWABLE = new Set(["image/png", "image/jpeg", "image/gif", "image/webp", "image/avif"]);
|
|
162
167
|
/** Image types a browser renders without running code; SVG is left out on purpose. */
|
|
@@ -239,7 +244,7 @@ export function draftCard(d) {
|
|
|
239
244
|
return h `<article class="card draft" id="draft-${d.id}">
|
|
240
245
|
<div class="meta">
|
|
241
246
|
<span class="badge draft">${S.draft}</span>
|
|
242
|
-
${mailboxBadge(d
|
|
247
|
+
${mailboxBadge(draftAccount(d))}
|
|
243
248
|
<span>${d.edited_by_human ? S.editedByHuman : S.byAgent} · ${formatDate(d.created_at)}</span>
|
|
244
249
|
</div>
|
|
245
250
|
<div class="draft-head">
|
|
@@ -263,7 +268,7 @@ export function draftEditor(d, form, conflict) {
|
|
|
263
268
|
<div class="grabber" aria-hidden="true"></div>
|
|
264
269
|
<div class="drop-hint">${S.dropFiles}</div>
|
|
265
270
|
<button type="button" class="icon-btn sheet-close" data-close aria-label="${S.close}">${icon("close")}</button>
|
|
266
|
-
<div class="sheet-head"><span class="badge draft">${S.draft}</span>${mailboxBadge(d
|
|
271
|
+
<div class="sheet-head"><span class="badge draft">${S.draft}</span>${mailboxBadge(draftAccount(d))}</div>
|
|
267
272
|
${when(d.note, () => h `<div class="note">${d.note}</div>`)}
|
|
268
273
|
${when(conflict, () => h `<div class="sheet-conflict">
|
|
269
274
|
<p class="warn">${S.conflictTitle}</p>
|
|
@@ -307,10 +312,16 @@ export function draftFiles(d, error) {
|
|
|
307
312
|
export function draftDone(id, text) {
|
|
308
313
|
return h `<article class="card notice" id="draft-${id}">${text}</article>`;
|
|
309
314
|
}
|
|
315
|
+
/** A list's title: the session's sending domains, with the list's name beside them. */
|
|
316
|
+
function listTitle(domains, label) {
|
|
317
|
+
return domains.length
|
|
318
|
+
? h `<h1>${domains.join(" · ")} <small>${label}</small></h1>`
|
|
319
|
+
: h `<h1>${label}</h1>`;
|
|
320
|
+
}
|
|
310
321
|
/** Drafts waiting for review, listed like the inbox; each opens its thread. */
|
|
311
|
-
export function draftList(drafts, current) {
|
|
322
|
+
export function draftList(drafts, domains, current) {
|
|
312
323
|
return h `<section class="list">
|
|
313
|
-
<header class="list-head"
|
|
324
|
+
<header class="list-head">${listTitle(domains, S.navDrafts)}</header>
|
|
314
325
|
${drafts.length ? join(drafts.map(d => h `<a class="row" href="/drafts/${d.id}" ${raw(d.id === current ? 'aria-current="page"' : "")}>
|
|
315
326
|
<span class="avatar" aria-hidden="true">${initials(d.to[0] ?? d.mailbox)}</span>
|
|
316
327
|
<span class="row-main">
|
|
@@ -334,13 +345,13 @@ export function threadList(threads, opts) {
|
|
|
334
345
|
const tab = (status, label) => h `<a class="chip" href="/inbox?${inboxQuery({ ...filter, status })}" ${raw(filter.status === status ? 'aria-current="page"' : "")}>${label}</a>`;
|
|
335
346
|
return h `<section class="list">
|
|
336
347
|
<header class="list-head">
|
|
337
|
-
|
|
348
|
+
${listTitle(opts.domains, S.navInbox)}
|
|
338
349
|
<form class="filters" method="get" action="/inbox">
|
|
339
350
|
<input type="hidden" name="status" value="${filter.status}">
|
|
340
351
|
<nav class="chips" aria-label="${S.filter}">${tab("unanswered", S.filterPending)}${tab("all", S.filterAll)}${tab("archived", S.filterArchived)}</nav>
|
|
341
|
-
${when(opts.
|
|
352
|
+
${when(opts.accounts.length > 1, () => h `<span class="select"><select name="mailbox" aria-label="${S.allMailboxes}" onchange="this.form.submit()">
|
|
342
353
|
<option value="">${S.allMailboxes}</option>
|
|
343
|
-
${join(opts.
|
|
354
|
+
${join(opts.accounts.map(m => h `<option value="${m}" ${raw(m === filter.mailbox ? "selected" : "")}>${m}</option>`))}
|
|
344
355
|
</select></span>`)}
|
|
345
356
|
</form>
|
|
346
357
|
</header>
|
|
@@ -348,15 +359,15 @@ export function threadList(threads, opts) {
|
|
|
348
359
|
</section>`;
|
|
349
360
|
}
|
|
350
361
|
function threadRow(t, opts) {
|
|
351
|
-
const people = t.participants.filter(p => !opts.own
|
|
362
|
+
const people = t.participants.filter(p => !opts.own(p));
|
|
352
363
|
return h `<a class="row ${t.unread ? "unread" : ""}" href="/threads/${t.id}?${inboxQuery(opts.filter)}" ${raw(t.id === opts.current ? 'aria-current="page"' : "")}>
|
|
353
364
|
<span class="avatar" aria-hidden="true">${initials(people[0] ?? t.mailbox)}</span>
|
|
354
365
|
<span class="row-main">
|
|
355
366
|
<span class="row-top"><span class="who">${people.join(", ") || t.mailbox}</span><time datetime="${t.last_at}">${formatDate(t.last_at)}</time></span>
|
|
356
367
|
<span class="row-subject">${t.subject || "—"}</span>
|
|
357
|
-
${when(t.has_draft || opts.
|
|
368
|
+
${when(t.has_draft || opts.accounts.length > 1 || t.unread, () => h `<span class="row-tags">
|
|
358
369
|
${when(t.has_draft, () => h `<span class="badge draft">${S.hasDraft}</span>`)}
|
|
359
|
-
${when(opts.
|
|
370
|
+
${when(opts.accounts.length > 1, () => mailboxBadge(opts.accountOf(t)))}
|
|
360
371
|
${when(t.unread, () => h `<span class="dot" title="${S.unread}"></span>`)}
|
|
361
372
|
</span>`)}
|
|
362
373
|
</span>
|
|
@@ -370,8 +381,8 @@ export function inboxPage(list, thread) {
|
|
|
370
381
|
export function threadView(thread, entries, ctx, opts) {
|
|
371
382
|
const query = inboxQuery(opts.filter);
|
|
372
383
|
const rows = contextRows(ctx);
|
|
373
|
-
const people = thread.participants.filter(p => !opts.own
|
|
374
|
-
const title = h `<span class="thread-subject">${thread.subject || "—"}</span><span class="thread-meta">${[...people,
|
|
384
|
+
const people = thread.participants.filter(p => !opts.own(p));
|
|
385
|
+
const title = h `<span class="thread-subject">${thread.subject || "—"}</span><span class="thread-meta">${[...people, opts.account].join(" · ")}</span>`;
|
|
375
386
|
const items = [];
|
|
376
387
|
let day = "";
|
|
377
388
|
for (const entry of entries) {
|
|
@@ -426,7 +437,9 @@ export function devicesPage(sessions, currentId) {
|
|
|
426
437
|
<span class="row-by">${S.signedIn} ${formatDate(s.created_at)} · ${S.createdBy} ${s.created_by}</span>
|
|
427
438
|
</span>
|
|
428
439
|
</span>
|
|
429
|
-
${
|
|
440
|
+
${s.id === currentId
|
|
441
|
+
? h `<form method="post" action="/logout"><button class="danger">${S.logout}</button></form>`
|
|
442
|
+
: h `<button class="danger" hx-post="/devices/${s.id}/revoke" hx-target="#session-${s.id}" hx-swap="delete">${S.revoke}</button>`}
|
|
430
443
|
</div>`)) : h `<p class="empty">${S.devicesEmpty}</p>`}
|
|
431
444
|
</section>`;
|
|
432
445
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inboxer",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"description": "A self-hosted mail layer for agents: persists every inbound and outbound email, exposes an MCP server, and ships a minimal UI to review drafts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|