feat(editor): F4.6e the e-mail program and e-mail server on a computer's desktop
The oracle MailWindowRun uses Java's e-mail windows as a person does and answers their dialogs. The core sets and saves the program's account, deletes a mail, checks a form as Java's window does, and gives the server its domain, new and removed accounts and the window's own line; the room sends both programs' views and takes their actions; the editor has both windows. Better than Java: a name field for a new account, a user name the server has is refused, deleting hits the folder shown, a new domain goes into the accounts file at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,4 +2,5 @@
|
||||
export * from './host.js';
|
||||
export * from './sim.js';
|
||||
export * from './terminal.js';
|
||||
export * from './mail.js';
|
||||
export * from './web.js';
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// 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 "<sender> 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> ')}`,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user