// What the e-mail program's and the e-mail server's windows show, as the // room keeps them and every client shows them (plan §7.3), after // GUIApplicationEmailAnwendungWindow and GUIApplicationEmailServerWindow // (measured with tools/java-oracle's MailWindowRun). import { addressText, type EmailClientAccount, type Mail } from '@mdg-filius/core'; /** The e-mail program: its account (null before one is set) and its two folders, oldest first. */ export interface EmailClientView { readonly account: EmailClientAccount | null; readonly inbox: readonly Mail[]; readonly sent: readonly Mail[]; } /** The e-mail server: its button, its domain, and each account with the number of mails it holds. */ export interface EmailServerView { readonly active: boolean; readonly domain: string; readonly accounts: readonly { readonly username: string; readonly mails: number }[]; } /** posteingangAktualisieren: a received mail's row — its sender's name, else its address, nothing without a sender — and its subject. */ export function inboxRow(mail: Mail): readonly [string, string] { const sender = mail.sender === null ? '' : (mail.sender.name ?? mail.sender.mailAddress ?? ''); return [sender, mail.subject ?? '']; } /** gesendeteAktualisieren: a sent mail's row — its recipients as Email.holeEmpfaengerListe writes them — and its subject. */ export function sentRow(mail: Mail): readonly [string, string] { return [mail.to.map((each) => addressText(each) ?? 'null').join(', '), mail.subject ?? '']; } /** * emailVerfassen with a mail to answer: to its sender, the subject after * Java's "RE:", the text quoted below " wrote:" (replyLayout: each * line after "> "). */ export function replyForm(mail: Mail, words: { readonly re: string; readonly wrote: string }): { readonly to: string; readonly subject: string; readonly text: string } { const sender = mail.sender === null ? 'null' : (addressText(mail.sender) ?? 'null'); return { to: sender, subject: `${words.re} ${mail.subject ?? 'null'}`, text: `\n\n${sender} ${words.wrote}\n> ${mail.text.replaceAll('\n', '\n> ')}`, }; }