inboxer 0.4.7 → 0.4.8
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/README.md +1 -1
- package/package.json +1 -1
- package/skills/inboxer/SKILL.md +2 -2
- package/src/core/mail.ts +41 -8
- package/src/core/threads.ts +2 -2
- package/src/ui/routes.ts +11 -10
- package/src/ui/views.ts +29 -15
package/README.md
CHANGED
|
@@ -146,7 +146,7 @@ With roster's default isolation the site runs in its own process, so the databas
|
|
|
146
146
|
| `ui.undoSec` | Seconds a Send or Discard in the UI waits before it happens, with an Undo button |
|
|
147
147
|
| `ui.maxUploadMb` | Largest file a reviewer can attach to a draft |
|
|
148
148
|
|
|
149
|
-
`mailboxes` is an object keyed by id rather than an array, so a per-environment override can replace one mailbox without repeating the others. Mail sent to an address that matches no mailbox lands in the reserved `catchall` mailbox,
|
|
149
|
+
`mailboxes` is an object keyed by id rather than an array, so a per-environment override can replace one mailbox without repeating the others. Mail sent to an address that matches no mailbox lands in the reserved `catchall` mailbox, grouped by that address. Replies go out from the address that was written to, with the name and signature of a mailbox on the same domain; the catch-all cannot start new mail.
|
|
150
150
|
|
|
151
151
|
## Providers
|
|
152
152
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inboxer",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
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",
|
package/skills/inboxer/SKILL.md
CHANGED
|
@@ -32,7 +32,7 @@ const config = {
|
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
- Every key above is required except the mailbox signatures and mailbox tokens; `createInboxer` throws on a missing or invalid one. There are no defaults.
|
|
35
|
-
- `mailboxes` is an object keyed by id. `catchall` is reserved: unknown recipients land there, and
|
|
35
|
+
- `mailboxes` is an object keyed by id. `catchall` is reserved: unknown recipients land there, grouped by the address they were written to. It answers as that address, with the name and signature of a mailbox on the same domain, and cannot start new mail.
|
|
36
36
|
- `provider.apiKey`, `provider.webhookSecret`, every token and `ui.cookieSecret` are secrets: keep them out of Git and out of logs.
|
|
37
37
|
|
|
38
38
|
## Serve
|
|
@@ -105,7 +105,7 @@ Rules for agents:
|
|
|
105
105
|
- `search` matches every term, ignoring case and accents, across subject, body, from and to; narrow with `mailbox`, `from`, `since`, `until`, `meta`. Pass `query`, `meta`, or both.
|
|
106
106
|
- Messages list their `attachments` (`inline: true` is an image embedded in the body). `get_attachment` returns the content: images as images you can look at, text as text, other files (PDF, documents) as an embedded resource. Files over `mcp.maxAttachmentMb` return an error. Agents cannot attach files to drafts; the reviewer can, in the UI, and they are listed in the draft's `attachments`.
|
|
107
107
|
- Threads, messages and drafts in results carry `url`, which opens them in the review UI (scrolled to the draft). When telling the user what you drafted or sent, include that `url`.
|
|
108
|
-
- Times are ISO 8601. `catchall`
|
|
108
|
+
- Times are ISO 8601. A `catchall` reply goes out from the address the message was written to; `list_threads` also takes that address as `mailbox`.
|
|
109
109
|
|
|
110
110
|
Context:
|
|
111
111
|
|
package/src/core/mail.ts
CHANGED
|
@@ -98,6 +98,7 @@ export class Mail {
|
|
|
98
98
|
readonly provider: MailProvider;
|
|
99
99
|
readonly cfg: InboxerConfig;
|
|
100
100
|
private readonly ownAddresses: Set<string>;
|
|
101
|
+
private readonly domains: Set<string>;
|
|
101
102
|
private readonly timers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
102
103
|
private readonly files: AttachmentFiles;
|
|
103
104
|
|
|
@@ -106,6 +107,7 @@ export class Mail {
|
|
|
106
107
|
this.provider = provider;
|
|
107
108
|
this.cfg = cfg;
|
|
108
109
|
this.ownAddresses = new Set(Object.values(cfg.mailboxes).map(m => bareAddress(m.address)));
|
|
110
|
+
this.domains = new Set(Object.values(cfg.mailboxes).map(m => domainOf(m.address)));
|
|
109
111
|
this.files = new AttachmentFiles(cfg.dataDir);
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -116,6 +118,30 @@ export class Mail {
|
|
|
116
118
|
].filter(m => reaches(scope, m.id));
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
/** A configured mailbox address or any other address on its domains, such as one the catch-all received. */
|
|
122
|
+
isOwn(address: string): boolean {
|
|
123
|
+
const bare = bareAddress(address);
|
|
124
|
+
return this.ownAddresses.has(bare) || this.domains.has(domainOf(bare));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** The first address on our domains that is not a configured mailbox: the one a catch-all message was written to. */
|
|
128
|
+
private catchAllAddress(addresses: string[]): string | null {
|
|
129
|
+
return addresses.map(bareAddress).find(a => this.domains.has(domainOf(a)) && !this.ownAddresses.has(a)) ?? null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** The account a thread belongs to: its mailbox or, in the catch-all, the address it was written to. */
|
|
133
|
+
accountOf(thread: Thread): string {
|
|
134
|
+
return thread.mailbox === CATCHALL ? this.catchAllAddress(thread.participants) ?? CATCHALL : thread.mailbox;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Mailboxes in scope, with the catch-all split into the addresses it has received mail for. */
|
|
138
|
+
async listAccounts(scope: Scope): Promise<string[]> {
|
|
139
|
+
const mailboxes = this.listMailboxes(scope).map(m => m.id).filter(id => id !== CATCHALL);
|
|
140
|
+
if (!reaches(scope, CATCHALL)) return mailboxes;
|
|
141
|
+
const caught = (await this.store.allThreads()).filter(t => t.mailbox === CATCHALL).map(t => this.accountOf(t));
|
|
142
|
+
return [...mailboxes, ...[...new Set(caught)].sort()];
|
|
143
|
+
}
|
|
144
|
+
|
|
119
145
|
// Out of scope reads as missing, so a scoped token cannot probe other mailboxes.
|
|
120
146
|
|
|
121
147
|
async requireMessage(id: string, scope: Scope): Promise<Message> {
|
|
@@ -147,7 +173,10 @@ export class Mail {
|
|
|
147
173
|
return CATCHALL;
|
|
148
174
|
}
|
|
149
175
|
|
|
150
|
-
|
|
176
|
+
/** Who sends for `id`; the catch-all answers as `address`, with the name and signature of a mailbox on that domain. */
|
|
177
|
+
private sendingMailbox(id: string, address: string | null): MailboxConfig {
|
|
178
|
+
const peer = id === CATCHALL && address ? Object.values(this.cfg.mailboxes).find(m => domainOf(m.address) === domainOf(address)) : undefined;
|
|
179
|
+
if (peer && address) return { name: peer.name, address: bareAddress(address), signatureText: peer.signatureText, signatureHtml: peer.signatureHtml };
|
|
151
180
|
const mailbox = this.cfg.mailboxes[id];
|
|
152
181
|
if (!mailbox) throw new InvalidRequestError(`Mailbox "${id}" cannot send (configured: ${Object.keys(this.cfg.mailboxes).join(", ")})`);
|
|
153
182
|
return mailbox;
|
|
@@ -189,7 +218,7 @@ export class Mail {
|
|
|
189
218
|
participants,
|
|
190
219
|
at: inbound.receivedAt,
|
|
191
220
|
},
|
|
192
|
-
this.
|
|
221
|
+
address => this.isOwn(address),
|
|
193
222
|
this.cfg.threadWindowDays,
|
|
194
223
|
);
|
|
195
224
|
const message: Message = {
|
|
@@ -275,7 +304,7 @@ export class Mail {
|
|
|
275
304
|
const threads = (await this.store.allThreads()).filter(t => {
|
|
276
305
|
if (!reaches(scope, t.mailbox)) return false;
|
|
277
306
|
if (byMeta && !byMeta(t.id, t.participants)) return false;
|
|
278
|
-
if (input.mailbox && t.mailbox !== input.mailbox) return false;
|
|
307
|
+
if (input.mailbox && t.mailbox !== input.mailbox && this.accountOf(t) !== input.mailbox) return false;
|
|
279
308
|
if (input.label && !t.labels[input.label]) return false;
|
|
280
309
|
if (input.since && t.last_at < input.since) return false;
|
|
281
310
|
if (status === "archived") return t.archived;
|
|
@@ -313,7 +342,7 @@ export class Mail {
|
|
|
313
342
|
|
|
314
343
|
/** The thread's own context and the contacts of its external participants that have one. */
|
|
315
344
|
async contextOf(thread: Thread): Promise<{ context: Context | null; contacts: Contact[] }> {
|
|
316
|
-
const external = thread.participants.filter(p => !this.
|
|
345
|
+
const external = thread.participants.filter(p => !this.isOwn(p));
|
|
317
346
|
const contacts = (await Promise.all(external.map(p => this.store.getContact(p)))).filter((c): c is Contact => !!c);
|
|
318
347
|
return { context: await this.store.getThreadContext(thread.id), contacts };
|
|
319
348
|
}
|
|
@@ -417,14 +446,17 @@ export class Mail {
|
|
|
417
446
|
private replyDefaults(original: Message, given: { mailbox?: string; to?: string[] }, replyAll: boolean) {
|
|
418
447
|
const mailbox = given.mailbox ?? original.mailbox;
|
|
419
448
|
const to = given.to ?? (original.direction === "in" ? (original.reply_to.length ? original.reply_to : [original.from]) : original.to);
|
|
420
|
-
const
|
|
449
|
+
const caught = mailbox === CATCHALL ? this.catchAllAddress(original.direction === "out" ? [original.from] : [...original.to, ...original.cc]) : null;
|
|
450
|
+
const sender = this.sendingMailbox(mailbox, caught);
|
|
451
|
+
const already = new Set([bareAddress(sender.address), ...to.map(bareAddress)]);
|
|
421
452
|
const cc = replyAll ? [...original.to, ...original.cc].filter(a => !already.has(bareAddress(a))) : [];
|
|
422
|
-
return { mailbox, to, cc, subject: replySubject(original.subject) };
|
|
453
|
+
return { mailbox, sender, to, cc, subject: replySubject(original.subject) };
|
|
423
454
|
}
|
|
424
455
|
|
|
425
456
|
private async createDraftUnlocked(input: CreateDraftInput, actor: Actor): Promise<Message> {
|
|
426
457
|
const now = new Date().toISOString();
|
|
427
458
|
let mailbox: string;
|
|
459
|
+
let sender: MailboxConfig;
|
|
428
460
|
let to: string[];
|
|
429
461
|
let cc = input.cc ?? [];
|
|
430
462
|
let subject: string;
|
|
@@ -436,6 +468,7 @@ export class Mail {
|
|
|
436
468
|
const original = await this.requireMessage(input.replyToId, actor.scope);
|
|
437
469
|
const defaults = this.replyDefaults(original, input, !!input.replyAll && !input.cc);
|
|
438
470
|
mailbox = defaults.mailbox;
|
|
471
|
+
sender = defaults.sender;
|
|
439
472
|
to = defaults.to;
|
|
440
473
|
if (!input.cc) cc = defaults.cc;
|
|
441
474
|
subject = input.subject ?? defaults.subject;
|
|
@@ -447,11 +480,11 @@ export class Mail {
|
|
|
447
480
|
if (!input.to?.length) throw new InvalidRequestError("to is required when not replying");
|
|
448
481
|
if (input.subject === undefined) throw new InvalidRequestError("subject is required when not replying");
|
|
449
482
|
mailbox = input.mailbox;
|
|
483
|
+
sender = this.sendingMailbox(mailbox, null);
|
|
450
484
|
to = input.to;
|
|
451
485
|
subject = input.subject;
|
|
452
486
|
threadId = nid();
|
|
453
487
|
}
|
|
454
|
-
const sender = this.sendingMailbox(mailbox);
|
|
455
488
|
if (!reaches(actor.scope, mailbox)) throw new InvalidRequestError(`Mailbox "${mailbox}" is not available to ${actor.name}`);
|
|
456
489
|
|
|
457
490
|
const draft: Message = {
|
|
@@ -650,7 +683,7 @@ export class Mail {
|
|
|
650
683
|
*/
|
|
651
684
|
private async sendDraftUnlocked(id: string, actor: Actor): Promise<Message> {
|
|
652
685
|
const draft = await this.requireDraft(id, actor.scope);
|
|
653
|
-
const sender = this.sendingMailbox(draft.mailbox);
|
|
686
|
+
const sender = this.sendingMailbox(draft.mailbox, draft.from);
|
|
654
687
|
if (!draft.message_id) {
|
|
655
688
|
draft.message_id = `<${randomUUID()}@${domainOf(sender.address)}>`;
|
|
656
689
|
await this.store.putMessage(draft);
|
package/src/core/threads.ts
CHANGED
|
@@ -30,7 +30,7 @@ export interface ThreadLookup {
|
|
|
30
30
|
export async function resolveThreadId(
|
|
31
31
|
store: Store,
|
|
32
32
|
lookup: ThreadLookup,
|
|
33
|
-
|
|
33
|
+
isOwn: (address: string) => boolean,
|
|
34
34
|
windowDays: number,
|
|
35
35
|
): Promise<string> {
|
|
36
36
|
for (const ref of [lookup.inReplyTo, ...[...lookup.references].reverse()]) {
|
|
@@ -41,7 +41,7 @@ export async function resolveThreadId(
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
const subject = normalizeSubject(lookup.subject);
|
|
44
|
-
const external = new Set(lookup.participants.filter(p => !
|
|
44
|
+
const external = new Set(lookup.participants.filter(p => !isOwn(p)));
|
|
45
45
|
if (subject && external.size) {
|
|
46
46
|
const since = new Date(lookup.at).getTime() - windowDays * DAY_MS;
|
|
47
47
|
const match = (await store.allThreads())
|
package/src/ui/routes.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context, Hono } from "hono";
|
|
2
2
|
import { deleteCookie, getCookie, getSignedCookie, setCookie, setSignedCookie } from "hono/cookie";
|
|
3
3
|
import type { Access } from "../auth.ts";
|
|
4
|
-
import {
|
|
4
|
+
import { domainOf, splitAddresses } from "../core/address.ts";
|
|
5
5
|
import { ConflictError, InvalidRequestError, toView, type Mail, type MessageView, type ThreadStatus } from "../core/mail.ts";
|
|
6
6
|
import { CATCHALL, type Actor, type InboxerConfig, type Message, type Session } from "../types.ts";
|
|
7
7
|
import { S } from "./strings.ts";
|
|
@@ -33,12 +33,12 @@ export function registerUi(app: Hono<UiEnv>, mail: Mail, access: Access, cfg: In
|
|
|
33
33
|
const secret = cfg.ui.cookieSecret;
|
|
34
34
|
const cookieOptions = { httpOnly: true, secure: true, sameSite: "Lax", path: "/", maxAge: COOKIE_MAX_AGE } as const;
|
|
35
35
|
|
|
36
|
-
const own =
|
|
37
|
-
/** Recipients that are our own
|
|
36
|
+
const own = (address: string): boolean => mail.isOwn(address);
|
|
37
|
+
/** Recipients that are our own addresses are implied by the mailbox badge. */
|
|
38
38
|
const shown = (m: MessageView): MessageView => ({
|
|
39
39
|
...m,
|
|
40
|
-
to: m.to.filter(a => !own
|
|
41
|
-
cc: m.cc.filter(a => !own
|
|
40
|
+
to: m.to.filter(a => !own(a)),
|
|
41
|
+
cc: m.cc.filter(a => !own(a)),
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
/** Mailboxes a session can send from: every one in its scope but the catch-all. */
|
|
@@ -210,8 +210,8 @@ export function registerUi(app: Hono<UiEnv>, mail: Mail, access: Access, cfg: In
|
|
|
210
210
|
const session = c.get("session");
|
|
211
211
|
const filter = inboxFilter(c);
|
|
212
212
|
const threads = await mail.listThreads({ mailbox: filter.mailbox || undefined, status: filter.status as ThreadStatus, limit: 200 }, session.scope);
|
|
213
|
-
const
|
|
214
|
-
return V.threadList(threads, {
|
|
213
|
+
const accounts = await mail.listAccounts(session.scope);
|
|
214
|
+
return V.threadList(threads, { accounts, accountOf: t => mail.accountOf(t), domains: domainsOf(session), filter, own, current });
|
|
215
215
|
};
|
|
216
216
|
|
|
217
217
|
app.get("/inbox", async c => page(c, S.navInbox, V.inboxPage(await threadList(c, null), null), "inbox"));
|
|
@@ -225,13 +225,14 @@ export function registerUi(app: Hono<UiEnv>, mail: Mail, access: Access, cfg: In
|
|
|
225
225
|
thread = await mail.requireThread(id, session.scope);
|
|
226
226
|
}
|
|
227
227
|
const { messages, context, contacts } = await mail.getThread(id, session.scope);
|
|
228
|
-
const people = thread.participants.filter(p => !own
|
|
228
|
+
const people = thread.participants.filter(p => !own(p));
|
|
229
229
|
const entries = await Promise.all(messages.map(async m => ({
|
|
230
230
|
at: m.date,
|
|
231
231
|
view: m.status === "draft" ? V.draftCard(await mail.store.requireMessage(m.id)) : V.messageBubble(shown(m), people.length > 1),
|
|
232
232
|
})));
|
|
233
|
-
const
|
|
234
|
-
|
|
233
|
+
const account = mail.accountOf(thread);
|
|
234
|
+
const reply = { allowed: account !== CATCHALL && (thread.mailbox === CATCHALL || senders(session).some(m => m.id === thread.mailbox)), replyAll: people.length > 1 };
|
|
235
|
+
return { thread, view: V.threadView(thread, entries, { context, contacts }, { back, filter: inboxFilter(c), own, account, reply }) };
|
|
235
236
|
};
|
|
236
237
|
|
|
237
238
|
app.get("/threads/:id", async c => {
|
package/src/ui/views.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { html, raw } from "hono/html";
|
|
|
2
2
|
import type { HtmlEscapedString } from "hono/utils/html";
|
|
3
3
|
import { bareAddress } from "../core/address.ts";
|
|
4
4
|
import type { MessageView } from "../core/mail.ts";
|
|
5
|
-
import type
|
|
5
|
+
import { CATCHALL, type Contact, type Context, type Message, type Session, type Thread } from "../types.ts";
|
|
6
6
|
import { ASSETS } from "./assets.ts";
|
|
7
7
|
import { S } from "./strings.ts";
|
|
8
8
|
|
|
@@ -195,8 +195,13 @@ export function signIn(token: string, valid: boolean): View {
|
|
|
195
195
|
</div>`;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
/** An account by its mailbox id, or by the local part of an address the catch-all received. */
|
|
199
|
+
function mailboxBadge(account: string): View {
|
|
200
|
+
return h`<span class="badge mailbox">${account.includes("@") ? account.slice(0, account.lastIndexOf("@")) : account}</span>`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function draftAccount(d: Message): string {
|
|
204
|
+
return d.mailbox === CATCHALL ? bareAddress(d.from) : d.mailbox;
|
|
200
205
|
}
|
|
201
206
|
|
|
202
207
|
const PREVIEWABLE = new Set(["image/png", "image/jpeg", "image/gif", "image/webp", "image/avif"]);
|
|
@@ -290,7 +295,7 @@ export function draftCard(d: Message): View {
|
|
|
290
295
|
return h`<article class="card draft" id="draft-${d.id}">
|
|
291
296
|
<div class="meta">
|
|
292
297
|
<span class="badge draft">${S.draft}</span>
|
|
293
|
-
${mailboxBadge(d
|
|
298
|
+
${mailboxBadge(draftAccount(d))}
|
|
294
299
|
<span>${d.edited_by_human ? S.editedByHuman : S.byAgent} · ${formatDate(d.created_at)}</span>
|
|
295
300
|
</div>
|
|
296
301
|
<div class="draft-head">
|
|
@@ -322,7 +327,7 @@ export function draftEditor(d: Message, form: DraftForm, conflict: Message | nul
|
|
|
322
327
|
<div class="grabber" aria-hidden="true"></div>
|
|
323
328
|
<div class="drop-hint">${S.dropFiles}</div>
|
|
324
329
|
<button type="button" class="icon-btn sheet-close" data-close aria-label="${S.close}">${icon("close")}</button>
|
|
325
|
-
<div class="sheet-head"><span class="badge draft">${S.draft}</span>${mailboxBadge(d
|
|
330
|
+
<div class="sheet-head"><span class="badge draft">${S.draft}</span>${mailboxBadge(draftAccount(d))}</div>
|
|
326
331
|
${when(d.note, () => h`<div class="note">${d.note}</div>`)}
|
|
327
332
|
${when(conflict, () => h`<div class="sheet-conflict">
|
|
328
333
|
<p class="warn">${S.conflictTitle}</p>
|
|
@@ -405,7 +410,7 @@ export function inboxQuery(filter: InboxFilter): string {
|
|
|
405
410
|
}
|
|
406
411
|
|
|
407
412
|
/** The thread list; on a wide screen it stays beside the open thread. */
|
|
408
|
-
export function threadList(threads: Thread[], opts:
|
|
413
|
+
export function threadList(threads: Thread[], opts: ThreadListOptions & { domains: string[] }): View {
|
|
409
414
|
const { filter } = opts;
|
|
410
415
|
const tab = (status: string, label: string) =>
|
|
411
416
|
h`<a class="chip" href="/inbox?${inboxQuery({ ...filter, status })}" ${raw(filter.status === status ? 'aria-current="page"' : "")}>${label}</a>`;
|
|
@@ -415,9 +420,9 @@ export function threadList(threads: Thread[], opts: { mailboxes: string[]; domai
|
|
|
415
420
|
<form class="filters" method="get" action="/inbox">
|
|
416
421
|
<input type="hidden" name="status" value="${filter.status}">
|
|
417
422
|
<nav class="chips" aria-label="${S.filter}">${tab("unanswered", S.filterPending)}${tab("all", S.filterAll)}${tab("archived", S.filterArchived)}</nav>
|
|
418
|
-
${when(opts.
|
|
423
|
+
${when(opts.accounts.length > 1, () => h`<span class="select"><select name="mailbox" aria-label="${S.allMailboxes}" onchange="this.form.submit()">
|
|
419
424
|
<option value="">${S.allMailboxes}</option>
|
|
420
|
-
${join(opts.
|
|
425
|
+
${join(opts.accounts.map(m => h`<option value="${m}" ${raw(m === filter.mailbox ? "selected" : "")}>${m}</option>`))}
|
|
421
426
|
</select></span>`)}
|
|
422
427
|
</form>
|
|
423
428
|
</header>
|
|
@@ -425,16 +430,25 @@ export function threadList(threads: Thread[], opts: { mailboxes: string[]; domai
|
|
|
425
430
|
</section>`;
|
|
426
431
|
}
|
|
427
432
|
|
|
428
|
-
|
|
429
|
-
|
|
433
|
+
interface ThreadListOptions {
|
|
434
|
+
/** Mailbox ids and catch-all addresses, as filter values. */
|
|
435
|
+
accounts: string[];
|
|
436
|
+
accountOf: (t: Thread) => string;
|
|
437
|
+
filter: InboxFilter;
|
|
438
|
+
own: (address: string) => boolean;
|
|
439
|
+
current: string | null;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function threadRow(t: Thread, opts: ThreadListOptions): View {
|
|
443
|
+
const people = t.participants.filter(p => !opts.own(p));
|
|
430
444
|
return h`<a class="row ${t.unread ? "unread" : ""}" href="/threads/${t.id}?${inboxQuery(opts.filter)}" ${raw(t.id === opts.current ? 'aria-current="page"' : "")}>
|
|
431
445
|
<span class="avatar" aria-hidden="true">${initials(people[0] ?? t.mailbox)}</span>
|
|
432
446
|
<span class="row-main">
|
|
433
447
|
<span class="row-top"><span class="who">${people.join(", ") || t.mailbox}</span><time datetime="${t.last_at}">${formatDate(t.last_at)}</time></span>
|
|
434
448
|
<span class="row-subject">${t.subject || "—"}</span>
|
|
435
|
-
${when(t.has_draft || opts.
|
|
449
|
+
${when(t.has_draft || opts.accounts.length > 1 || t.unread, () => h`<span class="row-tags">
|
|
436
450
|
${when(t.has_draft, () => h`<span class="badge draft">${S.hasDraft}</span>`)}
|
|
437
|
-
${when(opts.
|
|
451
|
+
${when(opts.accounts.length > 1, () => mailboxBadge(opts.accountOf(t)))}
|
|
438
452
|
${when(t.unread, () => h`<span class="dot" title="${S.unread}"></span>`)}
|
|
439
453
|
</span>`)}
|
|
440
454
|
</span>
|
|
@@ -452,11 +466,11 @@ export interface ThreadEntry {
|
|
|
452
466
|
}
|
|
453
467
|
|
|
454
468
|
/** The conversation, oldest first, with day separators, a reply box and the context panel. */
|
|
455
|
-
export function threadView(thread: Thread, entries: ThreadEntry[], ctx: ContextView, opts: { back: string; filter: InboxFilter; own:
|
|
469
|
+
export function threadView(thread: Thread, entries: ThreadEntry[], ctx: ContextView, opts: { back: string; filter: InboxFilter; own: (address: string) => boolean; account: string; reply: { allowed: boolean; replyAll: boolean } }): View {
|
|
456
470
|
const query = inboxQuery(opts.filter);
|
|
457
471
|
const rows = contextRows(ctx);
|
|
458
|
-
const people = thread.participants.filter(p => !opts.own
|
|
459
|
-
const title = h`<span class="thread-subject">${thread.subject || "—"}</span><span class="thread-meta">${[...people,
|
|
472
|
+
const people = thread.participants.filter(p => !opts.own(p));
|
|
473
|
+
const title = h`<span class="thread-subject">${thread.subject || "—"}</span><span class="thread-meta">${[...people, opts.account].join(" · ")}</span>`;
|
|
460
474
|
const items: View[] = [];
|
|
461
475
|
let day = "";
|
|
462
476
|
for (const entry of entries) {
|