mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 19:40:34 +00:00
feat(mail-ingest): admin card, review mark, inbox events and links, translations
- Admin settings (desktop and phone, self-hosted only): the instance switch,
how mail arrives (IMAP or a signed webhook) with its fields, the address
template, the AI allowance per person and day, a connection test and the
status in counts. Changed fields only are saved; secrets stay masked.
- The review mark of an imported booking takes its mark off: the pill in the
desktop dialog and a row in the phone's transport sheet ('Looks right'),
through the ordinary booking update. Its hint no longer speaks of airports.
- The inbox follows mailInbox:changed and mailInbox:settings, and
?inbox=mail (the 'bookings waiting' notification) opens it.
- mailIngestRepo: the online-only path the views take, answers parsed
against the shared contracts.
- Dropped 'read with AI' and the unused mail-review contract: the server
reads a passing AI failure again on its own.
- mailInbox, mailAdmin and the new reservation, settings and notification
strings in all 28 locales; the pending notice is a plural group.
- The live flight line on the booking cards is one of the card's fields,
full width on the phone; the phone's live card keeps its map to the middle.
- Admin flight and mail cards sit in the left column.
This commit is contained in:
@@ -0,0 +1,304 @@
|
||||
import { CheckCircle, Copy, Loader2, Mail, PlugZap, Save, XCircle } from 'lucide-react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import type { TranslationFn } from '../../../types';
|
||||
import { copyText } from '../../../utils/clipboard';
|
||||
import { relativeTime } from '../../../utils/relativeTime';
|
||||
import {
|
||||
SETTINGS_BUTTON,
|
||||
SETTINGS_BUTTON_PRIMARY,
|
||||
SettingRow,
|
||||
SettingRows,
|
||||
SettingsCard,
|
||||
SettingsHint,
|
||||
StatusPill,
|
||||
} from '../../Settings/settingsKit';
|
||||
import ToggleSwitch from '../../Settings/ToggleSwitch';
|
||||
import CustomSelect from '../../shared/CustomSelect';
|
||||
import { EditorField, GRID_2, INPUT, READONLY_BOX } from '../../shared/dialogParts';
|
||||
import { useToast } from '../../shared/Toast';
|
||||
import {
|
||||
TRANSPORTS,
|
||||
problemText,
|
||||
statusFacts,
|
||||
transportLabel,
|
||||
type MailAdminForm,
|
||||
type MailAdminProblem,
|
||||
} from './mailIngestAdminModel';
|
||||
import { useMailIngestAdmin, type MailIngestAdmin } from './useMailIngestAdmin';
|
||||
|
||||
type T = TranslationFn;
|
||||
|
||||
/** The address a mail service posts to, shown so the admin can paste it into the sender's settings. */
|
||||
function InboundUrl({ t }: { t: T }) {
|
||||
const toast = useToast();
|
||||
const url = `${window.location.origin}/api/mail-ingest/inbound`;
|
||||
return (
|
||||
<EditorField label={t('mailAdmin.inboundUrl')} hint={t('mailAdmin.inboundUrlHint')}>
|
||||
<div className="flex gap-2">
|
||||
<span className={READONLY_BOX}>{url}</span>
|
||||
<button
|
||||
type="button"
|
||||
className={SETTINGS_BUTTON}
|
||||
aria-label={t('mailAdmin.copyUrl')}
|
||||
onClick={() => void copyText(url).then((ok) => (ok ? toast.success(t('common.copied')) : undefined))}
|
||||
>
|
||||
<Copy size={14} strokeWidth={2} />
|
||||
</button>
|
||||
</div>
|
||||
</EditorField>
|
||||
);
|
||||
}
|
||||
|
||||
interface FieldsProps {
|
||||
admin: MailIngestAdmin;
|
||||
form: MailAdminForm;
|
||||
t: T;
|
||||
error: (p: MailAdminProblem) => ReactNode;
|
||||
}
|
||||
|
||||
function ImapFields({ admin, form, t, error }: FieldsProps) {
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className={GRID_2}>
|
||||
<EditorField label={t('mailAdmin.imap.host')} htmlFor="mail-imap-host">
|
||||
<input
|
||||
id="mail-imap-host"
|
||||
className={INPUT}
|
||||
value={form.imap_host}
|
||||
placeholder="imap.example.com"
|
||||
onChange={(e) => admin.set('imap_host', e.target.value)}
|
||||
/>
|
||||
</EditorField>
|
||||
<div className={GRID_2}>
|
||||
<EditorField label={t('mailAdmin.imap.port')} htmlFor="mail-imap-port" error={error('portInvalid')}>
|
||||
<input
|
||||
id="mail-imap-port"
|
||||
className={INPUT}
|
||||
inputMode="numeric"
|
||||
value={form.imap_port}
|
||||
onChange={(e) => admin.set('imap_port', e.target.value)}
|
||||
/>
|
||||
</EditorField>
|
||||
<EditorField label={t('mailAdmin.imap.tls')}>
|
||||
<CustomSelect
|
||||
value={form.imap_tls}
|
||||
onChange={(value) => admin.set('imap_tls', value === 'starttls' ? 'starttls' : 'tls')}
|
||||
options={[
|
||||
{ value: 'tls', label: 'TLS' },
|
||||
{ value: 'starttls', label: 'STARTTLS' },
|
||||
]}
|
||||
/>
|
||||
</EditorField>
|
||||
</div>
|
||||
</div>
|
||||
<div className={GRID_2}>
|
||||
<EditorField label={t('mailAdmin.imap.user')} htmlFor="mail-imap-user">
|
||||
<input
|
||||
id="mail-imap-user"
|
||||
className={INPUT}
|
||||
autoComplete="off"
|
||||
value={form.imap_user}
|
||||
onChange={(e) => admin.set('imap_user', e.target.value)}
|
||||
/>
|
||||
</EditorField>
|
||||
<EditorField label={t('mailAdmin.imap.pass')} htmlFor="mail-imap-pass">
|
||||
<input
|
||||
id="mail-imap-pass"
|
||||
className={INPUT}
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
value={form.imap_pass}
|
||||
onChange={(e) => admin.set('imap_pass', e.target.value)}
|
||||
/>
|
||||
</EditorField>
|
||||
</div>
|
||||
<EditorField
|
||||
label={t('mailAdmin.imap.mailbox')}
|
||||
htmlFor="mail-imap-mailbox"
|
||||
hint={t('mailAdmin.imap.mailboxHint')}
|
||||
>
|
||||
<input
|
||||
id="mail-imap-mailbox"
|
||||
className={INPUT}
|
||||
value={form.imap_mailbox}
|
||||
onChange={(e) => admin.set('imap_mailbox', e.target.value)}
|
||||
/>
|
||||
</EditorField>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function WebhookFields({ admin, form, t, error }: FieldsProps) {
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
<EditorField
|
||||
label={t('mailAdmin.webhook.secret')}
|
||||
htmlFor="mail-webhook-secret"
|
||||
hint={t('mailAdmin.webhook.secretHint')}
|
||||
error={error('secretShort')}
|
||||
>
|
||||
<input
|
||||
id="mail-webhook-secret"
|
||||
className={INPUT}
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
value={form.webhook_secret}
|
||||
onChange={(e) => admin.set('webhook_secret', e.target.value)}
|
||||
/>
|
||||
</EditorField>
|
||||
<InboundUrl t={t} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** How the import runs, in counts only: no subject, sender or content of a mail is ever shown here. */
|
||||
function StatusBlock({ admin, t, locale }: { admin: MailIngestAdmin; t: T; locale: string }) {
|
||||
const status = admin.status;
|
||||
if (!status) return null;
|
||||
const facts = statusFacts(status);
|
||||
const lastRead = status.last_ok_at
|
||||
? relativeTime(Date.parse(status.last_ok_at), locale)
|
||||
: t('mailAdmin.status.never');
|
||||
return (
|
||||
<div className="flex flex-col gap-2 rounded-[12px] border border-edge-faint bg-surface-secondary px-3.5 py-3">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-caption font-semibold uppercase tracking-[0.08em] text-content-faint">
|
||||
{t('mailAdmin.status.title')}
|
||||
</span>
|
||||
<StatusPill tone={status.last_error ? 'warning' : 'neutral'}>
|
||||
{t('mailAdmin.status.lastRead', { time: lastRead })}
|
||||
</StatusPill>
|
||||
</div>
|
||||
<div className="grid grid-cols-4 gap-2 max-sm:grid-cols-2">
|
||||
{[
|
||||
{ label: t('mailAdmin.status.mails'), value: facts.mails },
|
||||
{ label: t('mailAdmin.status.added'), value: facts.added },
|
||||
{ label: t('mailAdmin.status.waiting'), value: facts.waiting },
|
||||
{ label: t('mailAdmin.status.failed'), value: facts.failed },
|
||||
].map((f) => (
|
||||
<div key={f.label} className="min-w-0">
|
||||
<div className="truncate text-caption text-content-faint">{f.label}</div>
|
||||
<div className="text-body font-semibold tabular-nums text-content">{f.value}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{status.last_error && <SettingsHint className="text-warning">{status.last_error}</SettingsHint>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TestResult({ admin, t }: { admin: MailIngestAdmin; t: T }) {
|
||||
if (!admin.test) return null;
|
||||
return admin.test.ok ? (
|
||||
<StatusPill tone="success" icon={<CheckCircle size={12} strokeWidth={2.2} />}>
|
||||
{t('mailAdmin.test.ok')}
|
||||
</StatusPill>
|
||||
) : (
|
||||
<StatusPill tone="danger" icon={<XCircle size={12} strokeWidth={2.2} />}>
|
||||
{admin.test.error ?? t('mailAdmin.test.failed')}
|
||||
</StatusPill>
|
||||
);
|
||||
}
|
||||
|
||||
/** Everything under the switch: how mail arrives, its fields, then save, test and the status. */
|
||||
function Setup({ admin, form, t, locale }: { admin: MailIngestAdmin; form: MailAdminForm; t: T; locale: string }) {
|
||||
const error = (problem: MailAdminProblem) => (admin.problems.includes(problem) ? problemText(problem, t) : undefined);
|
||||
return (
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className={GRID_2}>
|
||||
<EditorField label={t('mailAdmin.transport.label')}>
|
||||
<CustomSelect
|
||||
value={form.transport}
|
||||
onChange={(value) => admin.set('transport', TRANSPORTS.find((x) => x === value) ?? 'off')}
|
||||
options={TRANSPORTS.map((x) => ({ value: x, label: transportLabel(x, t) }))}
|
||||
/>
|
||||
</EditorField>
|
||||
<EditorField
|
||||
label={t('mailAdmin.aiDaily')}
|
||||
htmlFor="mail-ai-daily"
|
||||
hint={t('mailAdmin.aiDailyHint')}
|
||||
error={error('dailyInvalid')}
|
||||
>
|
||||
<input
|
||||
id="mail-ai-daily"
|
||||
className={INPUT}
|
||||
inputMode="numeric"
|
||||
value={form.ai_per_user_daily}
|
||||
onChange={(e) => admin.set('ai_per_user_daily', e.target.value)}
|
||||
/>
|
||||
</EditorField>
|
||||
</div>
|
||||
<EditorField
|
||||
label={t('mailAdmin.template')}
|
||||
htmlFor="mail-template"
|
||||
hint={t('mailAdmin.templateHint', { token: '{token}' })}
|
||||
error={error('templateToken')}
|
||||
>
|
||||
<input
|
||||
id="mail-template"
|
||||
className={INPUT}
|
||||
value={form.address_template}
|
||||
placeholder="trek+{token}@example.com"
|
||||
onChange={(e) => admin.set('address_template', e.target.value)}
|
||||
/>
|
||||
</EditorField>
|
||||
{form.transport === 'imap' && <ImapFields admin={admin} form={form} t={t} error={error} />}
|
||||
{form.transport === 'webhook' && <WebhookFields admin={admin} form={form} t={t} error={error} />}
|
||||
<SettingsHint>{t('mailAdmin.envHint')}</SettingsHint>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
className={SETTINGS_BUTTON_PRIMARY}
|
||||
disabled={!admin.dirty || admin.problems.length > 0 || admin.saving}
|
||||
onClick={admin.save}
|
||||
>
|
||||
{admin.saving ? <Loader2 size={14} className="animate-spin" /> : <Save size={14} strokeWidth={2} />}
|
||||
{t('common.save')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={SETTINGS_BUTTON}
|
||||
disabled={admin.testing || admin.dirty || form.transport === 'off'}
|
||||
onClick={admin.runTest}
|
||||
>
|
||||
{admin.testing ? <Loader2 size={14} className="animate-spin" /> : <PlugZap size={14} strokeWidth={2} />}
|
||||
{t('mailAdmin.test.run')}
|
||||
</button>
|
||||
<TestResult admin={admin} t={t} />
|
||||
</div>
|
||||
<StatusBlock admin={admin} t={t} locale={locale} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The booking mail import in the admin settings of a self-hosted install: the
|
||||
* instance switch, how mail arrives (IMAP or a signed webhook), the forwarding
|
||||
* address template, the AI allowance per person and day, a connection test and
|
||||
* the status in counts. Not shown on a managed install, where the operator
|
||||
* runs the TREK Cloud relay.
|
||||
*/
|
||||
export default function MailIngestAdminCard() {
|
||||
const { t, locale } = useTranslation();
|
||||
const admin = useMailIngestAdmin(true);
|
||||
return (
|
||||
<SettingsCard icon={Mail} title={t('mailAdmin.title')} hint={t('mailAdmin.hint')}>
|
||||
<SettingRows>
|
||||
<SettingRow
|
||||
label={t('mailAdmin.enabled')}
|
||||
hint={t('mailAdmin.enabledHint')}
|
||||
control={
|
||||
<ToggleSwitch
|
||||
on={admin.enabled}
|
||||
label={t('mailAdmin.enabled')}
|
||||
disabled={!admin.loaded}
|
||||
onToggle={() => admin.toggle(!admin.enabled)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SettingRows>
|
||||
{admin.enabled && admin.form && <Setup admin={admin} form={admin.form} t={t} locale={locale} />}
|
||||
</SettingsCard>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
// FE-ADMIN-MAILINGEST-001 to FE-ADMIN-MAILINGEST-006
|
||||
import type { MailIngestAdminStatusResponse } from '@trek/shared';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
MASKED,
|
||||
TRANSPORTS,
|
||||
changesOf,
|
||||
enabledOf,
|
||||
fieldsOf,
|
||||
formOf,
|
||||
problemText,
|
||||
problemsOf,
|
||||
statusFacts,
|
||||
transportLabel,
|
||||
} from './mailIngestAdminModel';
|
||||
|
||||
const t = (key: string, params?: Record<string, string | number | null>) =>
|
||||
params ? `${key} ${JSON.stringify(params)}` : key;
|
||||
|
||||
describe('mailIngestAdminModel', () => {
|
||||
it('FE-ADMIN-MAILINGEST-001: reads the stored settings, and the defaults for what the server left out', () => {
|
||||
expect(formOf({})).toEqual({
|
||||
transport: 'off',
|
||||
address_template: '',
|
||||
imap_host: '',
|
||||
imap_port: '993',
|
||||
imap_tls: 'tls',
|
||||
imap_user: '',
|
||||
imap_pass: '',
|
||||
imap_mailbox: 'INBOX',
|
||||
webhook_secret: '',
|
||||
ai_per_user_daily: '10',
|
||||
});
|
||||
const form = formOf({
|
||||
mail_ingest_transport: 'imap',
|
||||
mail_ingest_imap_port: 143,
|
||||
mail_ingest_imap_tls: 'starttls',
|
||||
mail_ingest_imap_pass: MASKED,
|
||||
});
|
||||
expect(form).toMatchObject({ transport: 'imap', imap_port: '143', imap_tls: 'starttls', imap_pass: MASKED });
|
||||
// The Cloud relay is the operator's, never a choice in this form.
|
||||
expect(formOf({ mail_ingest_transport: 'cloud' }).transport).toBe('off');
|
||||
expect(enabledOf({ mail_ingest_enabled: 'true' })).toBe(true);
|
||||
expect(enabledOf({})).toBe(false);
|
||||
});
|
||||
|
||||
it('FE-ADMIN-MAILINGEST-002: a save carries only what changed, trimmed, under the stored keys', () => {
|
||||
const saved = formOf({ mail_ingest_imap_pass: MASKED });
|
||||
expect(changesOf(saved, saved)).toEqual({});
|
||||
const edited = { ...saved, transport: 'imap' as const, imap_host: ' imap.example.com ' };
|
||||
expect(changesOf(edited, saved)).toEqual({
|
||||
mail_ingest_transport: 'imap',
|
||||
mail_ingest_imap_host: 'imap.example.com',
|
||||
});
|
||||
});
|
||||
|
||||
it('FE-ADMIN-MAILINGEST-003: each transport shows only its own fields', () => {
|
||||
expect(fieldsOf('off')).toEqual([]);
|
||||
expect(fieldsOf('webhook')).toEqual(['webhook_secret']);
|
||||
expect(fieldsOf('imap')).toContain('imap_pass');
|
||||
});
|
||||
|
||||
it('FE-ADMIN-MAILINGEST-004: what stops a save is found before the server answers', () => {
|
||||
const base = formOf({});
|
||||
expect(problemsOf(base)).toEqual([]);
|
||||
expect(problemsOf({ ...base, transport: 'webhook', webhook_secret: 'short' })).toEqual(['secretShort']);
|
||||
// A stored secret comes back masked, and an empty one switches the webhook off: neither is a problem.
|
||||
expect(problemsOf({ ...base, transport: 'webhook', webhook_secret: MASKED })).toEqual([]);
|
||||
expect(problemsOf({ ...base, transport: 'webhook', webhook_secret: '' })).toEqual([]);
|
||||
expect(problemsOf({ ...base, transport: 'imap', imap_port: '70000' })).toEqual(['portInvalid']);
|
||||
expect(problemsOf({ ...base, address_template: 'trek@example.com' })).toEqual(['templateToken']);
|
||||
expect(problemsOf({ ...base, ai_per_user_daily: '2.5' })).toEqual(['dailyInvalid']);
|
||||
});
|
||||
|
||||
it('FE-ADMIN-MAILINGEST-005: the status card adds up the last day in counts', () => {
|
||||
const status: MailIngestAdminStatusResponse = {
|
||||
transport: 'imap',
|
||||
last_ok_at: null,
|
||||
last_error: null,
|
||||
lease_until: null,
|
||||
last_day: { by_status: { processed: 7, failed: 2, queued: 1 }, by_reason: {} },
|
||||
auto_applied: 5,
|
||||
undone: 0,
|
||||
ai_calls_today: 3,
|
||||
backlog: [2, 4],
|
||||
};
|
||||
expect(statusFacts(status)).toEqual({ mails: 10, added: 5, waiting: 6, failed: 2 });
|
||||
});
|
||||
|
||||
it('FE-ADMIN-MAILINGEST-006: every transport and problem has its words, {token} kept literal', () => {
|
||||
expect(TRANSPORTS.map((x) => transportLabel(x, t))).toEqual([
|
||||
'mailAdmin.transport.off',
|
||||
'mailAdmin.transport.imap',
|
||||
'mailAdmin.transport.webhook',
|
||||
]);
|
||||
expect(problemText('templateToken', t)).toContain('"token":"{token}"');
|
||||
expect(problemText('secretShort', t)).toBe('mailAdmin.problem.secretShort');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,157 @@
|
||||
import type { MailIngestAdminStatusResponse, MailIngestImapTls } from '@trek/shared';
|
||||
import type { TranslationFn } from '../../../types';
|
||||
|
||||
/**
|
||||
* The admin form of the booking mail import, as plain data: which stored app
|
||||
* setting each field is, how the server's answer becomes the form, which
|
||||
* fields changed, and what the status card says. Shared by the desktop card
|
||||
* and the phone's admin section; no React here.
|
||||
*/
|
||||
|
||||
/** The transports an admin picks on a self-hosted install; the TREK Cloud relay is set by the operator. */
|
||||
type MailAdminTransport = 'off' | 'imap' | 'webhook';
|
||||
|
||||
export interface MailAdminForm {
|
||||
transport: MailAdminTransport;
|
||||
address_template: string;
|
||||
imap_host: string;
|
||||
imap_port: string;
|
||||
imap_tls: MailIngestImapTls;
|
||||
imap_user: string;
|
||||
/** "••••••••" while a stored password is untouched; the server keeps it then. */
|
||||
imap_pass: string;
|
||||
imap_mailbox: string;
|
||||
/** Masked like the password once stored. */
|
||||
webhook_secret: string;
|
||||
ai_per_user_daily: string;
|
||||
}
|
||||
|
||||
export type MailAdminField = keyof MailAdminForm;
|
||||
|
||||
/** What the server sends instead of a stored secret, and takes back as "unchanged". */
|
||||
export const MASKED = '••••••••';
|
||||
|
||||
/** The secret the webhook signs with: empty switches it off, else at least this long. */
|
||||
const WEBHOOK_SECRET_MIN = 32;
|
||||
|
||||
const KEY: Record<MailAdminField, string> = {
|
||||
transport: 'mail_ingest_transport',
|
||||
address_template: 'mail_ingest_address_template',
|
||||
imap_host: 'mail_ingest_imap_host',
|
||||
imap_port: 'mail_ingest_imap_port',
|
||||
imap_tls: 'mail_ingest_imap_tls',
|
||||
imap_user: 'mail_ingest_imap_user',
|
||||
imap_pass: 'mail_ingest_imap_pass',
|
||||
imap_mailbox: 'mail_ingest_imap_mailbox',
|
||||
webhook_secret: 'mail_ingest_webhook_secret',
|
||||
ai_per_user_daily: 'mail_ingest_ai_per_user_daily',
|
||||
};
|
||||
|
||||
export const ENABLED_KEY = 'mail_ingest_enabled';
|
||||
|
||||
const str = (value: unknown, fallback: string): string =>
|
||||
typeof value === 'string' || typeof value === 'number' ? String(value) : fallback;
|
||||
|
||||
/** The form from the admin's app settings; a key the server leaves out has its default. */
|
||||
export function formOf(settings: Record<string, unknown>): MailAdminForm {
|
||||
const transport = str(settings[KEY.transport], 'off');
|
||||
const tls = str(settings[KEY.imap_tls], 'tls');
|
||||
return {
|
||||
transport: transport === 'imap' || transport === 'webhook' ? transport : 'off',
|
||||
address_template: str(settings[KEY.address_template], ''),
|
||||
imap_host: str(settings[KEY.imap_host], ''),
|
||||
imap_port: str(settings[KEY.imap_port], '993'),
|
||||
imap_tls: tls === 'starttls' ? 'starttls' : 'tls',
|
||||
imap_user: str(settings[KEY.imap_user], ''),
|
||||
imap_pass: str(settings[KEY.imap_pass], ''),
|
||||
imap_mailbox: str(settings[KEY.imap_mailbox], 'INBOX'),
|
||||
webhook_secret: str(settings[KEY.webhook_secret], ''),
|
||||
ai_per_user_daily: str(settings[KEY.ai_per_user_daily], '10'),
|
||||
};
|
||||
}
|
||||
|
||||
export function enabledOf(settings: Record<string, unknown>): boolean {
|
||||
return String(settings[ENABLED_KEY] ?? 'false') === 'true';
|
||||
}
|
||||
|
||||
/** Only what changed, under the stored keys, so a save never touches a field the admin left alone. */
|
||||
export function changesOf(form: MailAdminForm, saved: MailAdminForm): Record<string, string> {
|
||||
const patch: Record<string, string> = {};
|
||||
for (const field of Object.keys(KEY) as MailAdminField[]) {
|
||||
if (form[field] !== saved[field]) patch[KEY[field]] = form[field].trim();
|
||||
}
|
||||
return patch;
|
||||
}
|
||||
|
||||
/** The fields the chosen transport shows, so the form never asks for what will not be used. */
|
||||
export function fieldsOf(transport: MailAdminTransport): MailAdminField[] {
|
||||
switch (transport) {
|
||||
case 'imap':
|
||||
return ['imap_host', 'imap_port', 'imap_tls', 'imap_user', 'imap_pass', 'imap_mailbox'];
|
||||
case 'webhook':
|
||||
return ['webhook_secret'];
|
||||
case 'off':
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export type MailAdminProblem = 'secretShort' | 'portInvalid' | 'templateToken' | 'dailyInvalid';
|
||||
|
||||
/** What stops a save, checked here so the admin hears it before the server answers. */
|
||||
export function problemsOf(form: MailAdminForm): MailAdminProblem[] {
|
||||
const problems: MailAdminProblem[] = [];
|
||||
const secret = form.webhook_secret.trim();
|
||||
if (form.transport === 'webhook' && secret !== MASKED && secret.length > 0 && secret.length < WEBHOOK_SECRET_MIN) {
|
||||
problems.push('secretShort');
|
||||
}
|
||||
const port = Number(form.imap_port);
|
||||
if (form.transport === 'imap' && !(Number.isInteger(port) && port > 0 && port < 65536)) problems.push('portInvalid');
|
||||
if (form.address_template.trim() && !form.address_template.includes('{token}')) problems.push('templateToken');
|
||||
const daily = Number(form.ai_per_user_daily);
|
||||
if (!(Number.isInteger(daily) && daily >= 0 && daily <= 1000)) problems.push('dailyInvalid');
|
||||
return problems;
|
||||
}
|
||||
|
||||
/** The status card in numbers: mails of the last day, added on their own, open entries. */
|
||||
export function statusFacts(status: MailIngestAdminStatusResponse): {
|
||||
mails: number;
|
||||
added: number;
|
||||
waiting: number;
|
||||
failed: number;
|
||||
} {
|
||||
const byStatus = status.last_day.by_status;
|
||||
const mails = Object.values(byStatus).reduce<number>((sum, n) => sum + (n ?? 0), 0);
|
||||
return {
|
||||
mails,
|
||||
added: status.auto_applied,
|
||||
waiting: status.backlog.reduce((sum, n) => sum + n, 0),
|
||||
failed: byStatus.failed ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
/** A problem in the admin's words; a switch of literal keys so the i18n check sees each one. */
|
||||
export function problemText(problem: MailAdminProblem, t: TranslationFn): string {
|
||||
switch (problem) {
|
||||
case 'secretShort':
|
||||
return t('mailAdmin.problem.secretShort');
|
||||
case 'portInvalid':
|
||||
return t('mailAdmin.problem.portInvalid');
|
||||
case 'templateToken':
|
||||
return t('mailAdmin.problem.templateToken', { token: '{token}' });
|
||||
case 'dailyInvalid':
|
||||
return t('mailAdmin.problem.dailyInvalid');
|
||||
}
|
||||
}
|
||||
|
||||
export const TRANSPORTS: MailAdminTransport[] = ['off', 'imap', 'webhook'];
|
||||
|
||||
export function transportLabel(transport: MailAdminTransport, t: TranslationFn): string {
|
||||
switch (transport) {
|
||||
case 'off':
|
||||
return t('mailAdmin.transport.off');
|
||||
case 'imap':
|
||||
return t('mailAdmin.transport.imap');
|
||||
case 'webhook':
|
||||
return t('mailAdmin.transport.webhook');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
import type { MailIngestAdminStatusResponse, MailIngestAdminTestResponse } from '@trek/shared';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import { mailIngestRepo } from '../../../repo/mailIngestRepo';
|
||||
import { getApiErrorMessage } from '../../../types';
|
||||
import { useToast } from '../../shared/Toast';
|
||||
import {
|
||||
ENABLED_KEY,
|
||||
changesOf,
|
||||
enabledOf,
|
||||
formOf,
|
||||
problemsOf,
|
||||
type MailAdminField,
|
||||
type MailAdminForm,
|
||||
} from './mailIngestAdminModel';
|
||||
|
||||
/**
|
||||
* The admin card of the booking mail import, desktop and phone alike: the
|
||||
* instance switch (saved at once, as every switch in the admin settings), the
|
||||
* transport fields (saved together, only the changed ones), the connection
|
||||
* test and the status in counts. Loads once when shown.
|
||||
*/
|
||||
export function useMailIngestAdmin(active: boolean) {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
const [enabled, setEnabled] = useState(false);
|
||||
const [saved, setSaved] = useState<MailAdminForm | null>(null);
|
||||
const [form, setForm] = useState<MailAdminForm | null>(null);
|
||||
const [status, setStatus] = useState<MailIngestAdminStatusResponse | null>(null);
|
||||
const [test, setTest] = useState<MailIngestAdminTestResponse | null>(null);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [testing, setTesting] = useState(false);
|
||||
|
||||
const loadStatus = useCallback(async () => {
|
||||
try {
|
||||
setStatus(await mailIngestRepo.adminStatus());
|
||||
} catch {
|
||||
setStatus(null);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!active) return;
|
||||
let cancelled = false;
|
||||
void (async () => {
|
||||
try {
|
||||
const raw = await mailIngestRepo.adminSettings();
|
||||
if (cancelled) return;
|
||||
const loaded = formOf(raw);
|
||||
setEnabled(enabledOf(raw));
|
||||
setSaved(loaded);
|
||||
setForm(loaded);
|
||||
} catch {
|
||||
if (!cancelled) toast.error(t('mailAdmin.loadError'));
|
||||
}
|
||||
if (!cancelled) await loadStatus();
|
||||
})();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [active, loadStatus, t, toast]);
|
||||
|
||||
const toggle = async (on: boolean) => {
|
||||
setEnabled(on);
|
||||
try {
|
||||
await mailIngestRepo.saveAdminSettings({ [ENABLED_KEY]: on });
|
||||
void loadStatus();
|
||||
} catch (err: unknown) {
|
||||
setEnabled(!on);
|
||||
toast.error(getApiErrorMessage(err, t('common.error')));
|
||||
}
|
||||
};
|
||||
|
||||
const set = <K extends MailAdminField>(field: K, value: MailAdminForm[K]) =>
|
||||
setForm((current) => (current ? { ...current, [field]: value } : current));
|
||||
|
||||
const patch = form && saved ? changesOf(form, saved) : {};
|
||||
const problems = form ? problemsOf(form) : [];
|
||||
|
||||
const save = async () => {
|
||||
if (!form || Object.keys(patch).length === 0 || problems.length > 0) return;
|
||||
setSaving(true);
|
||||
try {
|
||||
await mailIngestRepo.saveAdminSettings(patch);
|
||||
setSaved(form);
|
||||
setTest(null);
|
||||
toast.success(t('common.saved'));
|
||||
void loadStatus();
|
||||
} catch (err: unknown) {
|
||||
toast.error(getApiErrorMessage(err, t('common.error')));
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const runTest = async () => {
|
||||
setTesting(true);
|
||||
try {
|
||||
setTest(await mailIngestRepo.adminTest());
|
||||
} catch (err: unknown) {
|
||||
setTest({ transport: form?.transport ?? 'off', ok: false, error: getApiErrorMessage(err, t('common.error')) });
|
||||
} finally {
|
||||
setTesting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
loaded: form !== null,
|
||||
enabled,
|
||||
toggle: (on: boolean) => void toggle(on),
|
||||
form,
|
||||
set,
|
||||
dirty: Object.keys(patch).length > 0,
|
||||
problems,
|
||||
saving,
|
||||
save: () => void save(),
|
||||
status,
|
||||
test,
|
||||
testing,
|
||||
runTest: () => void runTest(),
|
||||
};
|
||||
}
|
||||
|
||||
export type MailIngestAdmin = ReturnType<typeof useMailIngestAdmin>;
|
||||
@@ -14,8 +14,9 @@ import AssistantLauncher from '../Assistant/AssistantLauncher'
|
||||
import { resolvePluginIcon } from '../shared/PluginIcon'
|
||||
import { visibleManagedNavItems } from '../../managed'
|
||||
import { useCollapseOnOverflow } from '../../hooks/useCollapseOnOverflow'
|
||||
import { useMailIngestStore } from '../../store/mailIngestStore'
|
||||
import { useMailIngestStore, watchMailInbox } from '../../store/mailIngestStore'
|
||||
import { openMailInbox } from '../MailIngest/mailInboxOpener'
|
||||
import { useMailInboxLink } from '../MailIngest/useMailInboxLink'
|
||||
import MailInboxDialog from '../MailIngest/MailInboxDialog'
|
||||
|
||||
const ADDON_ICONS: Record<string, LucideIcon> = { CalendarDays, Briefcase, Globe, Compass, Bookmark }
|
||||
@@ -50,9 +51,12 @@ export default function Navbar({ tripTitle, tripId, onBack, showBack, onSettings
|
||||
const mailImport = useMailIngestStore(s => s.settings)
|
||||
const mailPending = useMailIngestStore(s => s.pending)
|
||||
const mailImportOn = !!mailImport?.available && mailImport.prefs.enabled
|
||||
useMailInboxLink(mailImportOn)
|
||||
const userId = user?.id
|
||||
useEffect(() => {
|
||||
if (userId) void useMailIngestStore.getState().loadSettings()
|
||||
if (!userId) return
|
||||
void useMailIngestStore.getState().loadSettings()
|
||||
return watchMailInbox()
|
||||
}, [userId])
|
||||
const darkMode = settings.dark_mode
|
||||
const dark = darkMode === true || darkMode === 'dark' || (darkMode === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
@@ -340,10 +344,10 @@ export default function Navbar({ tripTitle, tripId, onBack, showBack, onSettings
|
||||
{/* Bookings from forwarded mails that wait for a decision; only where the import is on. */}
|
||||
{mailImportOn && (
|
||||
<button type="button" onClick={() => { setUserMenuOpen(false); openMailInbox() }}
|
||||
className="flex w-full items-center gap-2 px-4 py-2 text-sm transition-colors text-content-secondary hover:bg-surface-hover">
|
||||
className="flex w-full items-center gap-2 px-4 py-2 text-body transition-colors text-content-secondary hover:bg-surface-hover">
|
||||
<Inbox className="w-4 h-4" />
|
||||
<span className="min-w-0 flex-1 truncate text-start">{t('mailInbox.title')}</span>
|
||||
{mailPending > 0 && <span className="rounded-full bg-accent px-1.5 text-xs font-semibold text-accent-text">{mailPending}</span>}
|
||||
{mailPending > 0 && <span className="rounded-full bg-accent px-1.5 text-caption font-semibold text-accent-text">{mailPending}</span>}
|
||||
</button>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { MailIngestInboxEntry } from '@trek/shared';
|
||||
import { Copy, FilePlus2, FileText, Inbox, Loader2, Mail, PencilLine, Plus, Sparkles, Trash2 } from 'lucide-react';
|
||||
import { Copy, FilePlus2, FileText, Inbox, Loader2, Mail, PencilLine, Plus, Trash2 } from 'lucide-react';
|
||||
import { useId, type ReactElement } from 'react';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { copyText } from '../../utils/clipboard';
|
||||
@@ -28,8 +28,6 @@ function actionLook(action: InboxAction, t: (key: string) => string): { icon: Re
|
||||
return { icon: <FilePlus2 size={14} strokeWidth={2} />, label: t('mailInbox.action.file') };
|
||||
case 'manual':
|
||||
return { icon: <PencilLine size={14} strokeWidth={2} />, label: t('mailInbox.action.manual') };
|
||||
case 'readAi':
|
||||
return { icon: <Sparkles size={14} strokeWidth={2} />, label: t('mailInbox.action.readAi') };
|
||||
case 'discard':
|
||||
return { icon: <Trash2 size={14} strokeWidth={2} />, label: t('mailInbox.action.discard') };
|
||||
}
|
||||
@@ -75,8 +73,8 @@ function Entry({ entry, inbox }: { entry: MailIngestInboxEntry; inbox: ReturnTyp
|
||||
<DialogIconButton
|
||||
label={t('mailInbox.settings.copy')}
|
||||
icon={<Copy size={13} strokeWidth={2} />}
|
||||
onClick={async () => {
|
||||
if (await copyText(code)) toast.success(t('common.copied'));
|
||||
onClick={() => {
|
||||
void copyText(code).then((ok) => ok && toast.success(t('common.copied')));
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { mailIngestAddressResponseSchema, type MailIngestAddress } from '@trek/shared';
|
||||
import type { MailIngestAddress } from '@trek/shared';
|
||||
import { Copy, Mail, Plus } from 'lucide-react';
|
||||
import { useEffect, useState, type ReactElement } from 'react';
|
||||
import { mailIngestApi } from '../../api/mailIngest';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { mailIngestRepo } from '../../repo/mailIngestRepo';
|
||||
import { useMailIngestStore } from '../../store/mailIngestStore';
|
||||
import { copyText } from '../../utils/clipboard';
|
||||
import { useToast } from '../shared/Toast';
|
||||
@@ -30,13 +30,15 @@ export default function TripMailForward({ tripId }: { tripId: number }): ReactEl
|
||||
useEffect(() => {
|
||||
if (!on) return;
|
||||
let live = true;
|
||||
mailIngestApi
|
||||
mailIngestRepo
|
||||
.tripAddress(tripId)
|
||||
.then((raw) => {
|
||||
const parsed = mailIngestAddressResponseSchema.safeParse(raw);
|
||||
if (live && parsed.success) setAddress(parsed.data.address);
|
||||
.then((found) => {
|
||||
if (live) setAddress(found);
|
||||
})
|
||||
.catch(() => {});
|
||||
.catch(() => {
|
||||
// No address yet, or none readable: the card offers to create one instead.
|
||||
if (live) setAddress(null);
|
||||
});
|
||||
return () => {
|
||||
live = false;
|
||||
};
|
||||
@@ -47,7 +49,7 @@ export default function TripMailForward({ tripId }: { tripId: number }): ReactEl
|
||||
const create = async () => {
|
||||
setCreating(true);
|
||||
try {
|
||||
setAddress(mailIngestAddressResponseSchema.parse(await mailIngestApi.createTripAddress(tripId)).address);
|
||||
setAddress(await mailIngestRepo.createTripAddress(tripId));
|
||||
} catch {
|
||||
toast.error(t('mailInbox.settings.saveError'));
|
||||
} finally {
|
||||
|
||||
@@ -52,20 +52,19 @@ function entry(
|
||||
|
||||
describe('mailInboxModel', () => {
|
||||
it('FE-MAILINBOX-MODEL-001: a read booking with a suggested trip is added in one tap, with every way out after it', () => {
|
||||
expect(actionsOf(entry(), false)).toEqual(['add', 'file', 'manual', 'discard']);
|
||||
expect(actionsOf(entry())).toEqual(['add', 'file', 'manual', 'discard']);
|
||||
});
|
||||
|
||||
it('FE-MAILINBOX-MODEL-002: without a suggestion the person chooses the trip', () => {
|
||||
expect(actionsOf(entry({ suggested_trip: null }), false)[0]).toBe('choose');
|
||||
expect(actionsOf(entry({ suggested_trip: null }))[0]).toBe('choose');
|
||||
});
|
||||
|
||||
it('FE-MAILINBOX-MODEL-003: a mail without a booking offers the document, the form, and AI only where it can help', () => {
|
||||
it('FE-MAILINBOX-MODEL-003: a mail without a booking offers the document and the form', () => {
|
||||
const none = entry(
|
||||
{ item: null, reason: 'not_a_booking' },
|
||||
{ attachments: [{ file_name: 'invoice.pdf', kind: 'pdf', size: 1 }] }
|
||||
);
|
||||
expect(actionsOf(none, false)).toEqual(['file', 'manual', 'discard']);
|
||||
expect(actionsOf(none, true)).toEqual(['file', 'manual', 'readAi', 'discard']);
|
||||
expect(actionsOf(none)).toEqual(['file', 'manual', 'discard']);
|
||||
});
|
||||
|
||||
it('FE-MAILINBOX-MODEL-004: a forwarding confirmation or a newsletter only informs', () => {
|
||||
|
||||
@@ -8,107 +8,71 @@ import type { MailIngestInboxEntry, MailIngestReason } from '@trek/shared';
|
||||
*/
|
||||
|
||||
/** The ways out of an entry, in the order the row offers them. */
|
||||
export type InboxAction = 'add' | 'choose' | 'file' | 'manual' | 'readAi' | 'discard';
|
||||
|
||||
/** Reasons where reading the mail again with AI is worth a try. */
|
||||
const AI_RETRY: ReadonlySet<MailIngestReason> = new Set([
|
||||
'ai_quota_exhausted',
|
||||
'ai_user_cap',
|
||||
'ai_provider_error',
|
||||
'ai_disabled',
|
||||
'not_a_booking',
|
||||
'mail_unreadable',
|
||||
]);
|
||||
export type InboxAction = 'add' | 'choose' | 'file' | 'manual' | 'discard';
|
||||
|
||||
/** Reasons that need no booking decision at all: the entry only informs. */
|
||||
const INFO_ONLY: ReadonlySet<MailIngestReason> = new Set(['forwarding_confirmation', 'newsletter', 'auto_reply']);
|
||||
|
||||
export function actionsOf(entry: MailIngestInboxEntry, aiAvailable: boolean): InboxAction[] {
|
||||
/**
|
||||
* A passing AI failure is read again by the server on its own; an allowance
|
||||
* used up leaves the form and the document, so there is no "read again" here.
|
||||
*/
|
||||
export function actionsOf(entry: MailIngestInboxEntry): InboxAction[] {
|
||||
const reason = entry.reason ?? entry.message.reason;
|
||||
if (reason && INFO_ONLY.has(reason)) return ['discard'];
|
||||
const actions: InboxAction[] = [];
|
||||
if (entry.item) actions.push(entry.suggested_trip ? 'add' : 'choose');
|
||||
if (entry.message.attachments.length > 0 || entry.item) actions.push('file');
|
||||
actions.push('manual');
|
||||
if (aiAvailable && reason && AI_RETRY.has(reason)) actions.push('readAi');
|
||||
actions.push('discard');
|
||||
return actions;
|
||||
}
|
||||
|
||||
type Translate = (key: string) => string;
|
||||
|
||||
/**
|
||||
* A reason in the reader's words. A switch of literal keys rather than a table,
|
||||
* so the i18n check sees every key in use and a new code fails the type check
|
||||
* here first.
|
||||
* A reason in the reader's words. A table of literal keys, so the i18n check
|
||||
* sees every key in use, and typed by the reason codes, so a new code fails
|
||||
* the type check here first.
|
||||
*/
|
||||
export function reasonText(reason: MailIngestReason, t: (key: string) => string): string {
|
||||
switch (reason) {
|
||||
case 'forwarding_confirmation':
|
||||
return t('mailInbox.reason.forwardingConfirmation');
|
||||
case 'newsletter':
|
||||
return t('mailInbox.reason.newsletter');
|
||||
case 'auto_reply':
|
||||
return t('mailInbox.reason.autoReply');
|
||||
case 'empty_mail':
|
||||
return t('mailInbox.reason.emptyMail');
|
||||
case 'mail_unreadable':
|
||||
return t('mailInbox.reason.mailUnreadable');
|
||||
case 'not_a_booking':
|
||||
return t('mailInbox.reason.notABooking');
|
||||
case 'too_large':
|
||||
return t('mailInbox.reason.tooLarge');
|
||||
case 'address_invalid':
|
||||
return t('mailInbox.reason.addressInvalid');
|
||||
case 'address_daily_limit':
|
||||
return t('mailInbox.reason.addressDailyLimit');
|
||||
case 'processing_failed':
|
||||
return t('mailInbox.reason.processingFailed');
|
||||
case 'ai_quota_exhausted':
|
||||
return t('mailInbox.reason.aiQuotaExhausted');
|
||||
case 'ai_disabled':
|
||||
return t('mailInbox.reason.aiDisabled');
|
||||
case 'ai_user_cap':
|
||||
return t('mailInbox.reason.aiUserCap');
|
||||
case 'ai_provider_error':
|
||||
return t('mailInbox.reason.aiProviderError');
|
||||
case 'no_trip_in_range':
|
||||
return t('mailInbox.reason.noTripInRange');
|
||||
case 'trip_ambiguous':
|
||||
return t('mailInbox.reason.tripAmbiguous');
|
||||
case 'trip_without_dates':
|
||||
return t('mailInbox.reason.tripWithoutDates');
|
||||
case 'no_edit_permission':
|
||||
return t('mailInbox.reason.noEditPermission');
|
||||
case 'demo_mode':
|
||||
return t('mailInbox.reason.demoMode');
|
||||
case 'outside_trip_dates':
|
||||
return t('mailInbox.reason.outsideTripDates');
|
||||
case 'source_mismatch':
|
||||
return t('mailInbox.reason.sourceMismatch');
|
||||
case 'implausible':
|
||||
return t('mailInbox.reason.implausible');
|
||||
case 'not_in_text':
|
||||
return t('mailInbox.reason.notInText');
|
||||
case 'image_only':
|
||||
return t('mailInbox.reason.imageOnly');
|
||||
case 'missing_critical_field':
|
||||
return t('mailInbox.reason.missingCriticalField');
|
||||
case 'missing_confirmation':
|
||||
return t('mailInbox.reason.missingConfirmation');
|
||||
case 'too_many_bookings':
|
||||
return t('mailInbox.reason.tooManyBookings');
|
||||
case 'change_or_cancellation':
|
||||
return t('mailInbox.reason.changeOrCancellation');
|
||||
case 'cancelled':
|
||||
return t('mailInbox.reason.cancelled');
|
||||
case 'possible_duplicate':
|
||||
return t('mailInbox.reason.possibleDuplicate');
|
||||
case 'change_available':
|
||||
return t('mailInbox.reason.changeAvailable');
|
||||
case 'conflict':
|
||||
return t('mailInbox.reason.conflict');
|
||||
case 'ask_first':
|
||||
return t('mailInbox.reason.askFirst');
|
||||
}
|
||||
const REASON_TEXT: Record<MailIngestReason, (t: Translate) => string> = {
|
||||
forwarding_confirmation: (t) => t('mailInbox.reason.forwardingConfirmation'),
|
||||
newsletter: (t) => t('mailInbox.reason.newsletter'),
|
||||
auto_reply: (t) => t('mailInbox.reason.autoReply'),
|
||||
empty_mail: (t) => t('mailInbox.reason.emptyMail'),
|
||||
mail_unreadable: (t) => t('mailInbox.reason.mailUnreadable'),
|
||||
not_a_booking: (t) => t('mailInbox.reason.notABooking'),
|
||||
too_large: (t) => t('mailInbox.reason.tooLarge'),
|
||||
address_invalid: (t) => t('mailInbox.reason.addressInvalid'),
|
||||
address_daily_limit: (t) => t('mailInbox.reason.addressDailyLimit'),
|
||||
processing_failed: (t) => t('mailInbox.reason.processingFailed'),
|
||||
ai_quota_exhausted: (t) => t('mailInbox.reason.aiQuotaExhausted'),
|
||||
ai_disabled: (t) => t('mailInbox.reason.aiDisabled'),
|
||||
ai_user_cap: (t) => t('mailInbox.reason.aiUserCap'),
|
||||
ai_provider_error: (t) => t('mailInbox.reason.aiProviderError'),
|
||||
no_trip_in_range: (t) => t('mailInbox.reason.noTripInRange'),
|
||||
trip_ambiguous: (t) => t('mailInbox.reason.tripAmbiguous'),
|
||||
trip_without_dates: (t) => t('mailInbox.reason.tripWithoutDates'),
|
||||
no_edit_permission: (t) => t('mailInbox.reason.noEditPermission'),
|
||||
demo_mode: (t) => t('mailInbox.reason.demoMode'),
|
||||
outside_trip_dates: (t) => t('mailInbox.reason.outsideTripDates'),
|
||||
source_mismatch: (t) => t('mailInbox.reason.sourceMismatch'),
|
||||
implausible: (t) => t('mailInbox.reason.implausible'),
|
||||
not_in_text: (t) => t('mailInbox.reason.notInText'),
|
||||
image_only: (t) => t('mailInbox.reason.imageOnly'),
|
||||
missing_critical_field: (t) => t('mailInbox.reason.missingCriticalField'),
|
||||
missing_confirmation: (t) => t('mailInbox.reason.missingConfirmation'),
|
||||
too_many_bookings: (t) => t('mailInbox.reason.tooManyBookings'),
|
||||
change_or_cancellation: (t) => t('mailInbox.reason.changeOrCancellation'),
|
||||
cancelled: (t) => t('mailInbox.reason.cancelled'),
|
||||
possible_duplicate: (t) => t('mailInbox.reason.possibleDuplicate'),
|
||||
change_available: (t) => t('mailInbox.reason.changeAvailable'),
|
||||
conflict: (t) => t('mailInbox.reason.conflict'),
|
||||
ask_first: (t) => t('mailInbox.reason.askFirst'),
|
||||
};
|
||||
|
||||
export function reasonText(reason: MailIngestReason, t: Translate): string {
|
||||
return REASON_TEXT[reason](t);
|
||||
}
|
||||
|
||||
/** The entry's headline: the booking's title, else the mail's subject, else nothing to show. */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { mailIngestSettingsResponseSchema, mailIngestUploadResponseSchema, type MailIngestPrefs } from '@trek/shared';
|
||||
import type { MailIngestPrefs } from '@trek/shared';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { mailIngestApi } from '../../api/mailIngest';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { mailIngestRepo } from '../../repo/mailIngestRepo';
|
||||
import { useMailIngestStore } from '../../store/mailIngestStore';
|
||||
import { copyText } from '../../utils/clipboard';
|
||||
import { useToast } from '../shared/Toast';
|
||||
@@ -37,10 +37,7 @@ export function useMailImportSettings() {
|
||||
if (!settings || saving) return;
|
||||
setSaving(key);
|
||||
try {
|
||||
const parsed = mailIngestSettingsResponseSchema.parse(
|
||||
await mailIngestApi.updateSettings({ [key]: !settings.prefs[key] })
|
||||
);
|
||||
setSettings(parsed);
|
||||
setSettings(await mailIngestRepo.updateSettings({ [key]: !settings.prefs[key] }));
|
||||
} catch {
|
||||
toast.error(t('mailInbox.settings.saveError'));
|
||||
} finally {
|
||||
@@ -64,7 +61,7 @@ export function useMailImportSettings() {
|
||||
setRenewArmed(false);
|
||||
setRenewing(true);
|
||||
try {
|
||||
await mailIngestApi.renewAddress();
|
||||
await mailIngestRepo.renewAddress();
|
||||
await loadSettings();
|
||||
toast.success(t('mailInbox.settings.renewed'));
|
||||
} catch {
|
||||
@@ -77,7 +74,7 @@ export function useMailImportSettings() {
|
||||
const upload = async (file: File) => {
|
||||
setUploading(true);
|
||||
try {
|
||||
const { duplicate } = mailIngestUploadResponseSchema.parse(await mailIngestApi.upload(file));
|
||||
const { duplicate } = await mailIngestRepo.upload(file);
|
||||
toast.success(duplicate ? t('mailInbox.settings.uploadDuplicate') : t('mailInbox.settings.uploaded'));
|
||||
} catch {
|
||||
toast.error(t('mailInbox.settings.uploadError'));
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import {
|
||||
mailIngestMessagePreviewResponseSchema,
|
||||
type MailIngestInboxEntry,
|
||||
type MailIngestMessagePreviewResponse,
|
||||
} from '@trek/shared';
|
||||
import type { MailIngestInboxEntry, MailIngestMessagePreviewResponse } from '@trek/shared';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { tripsApi } from '../../api/client';
|
||||
import { mailIngestApi, type MailIngestAction } from '../../api/mailIngest';
|
||||
import { useShallow } from 'zustand/react/shallow';
|
||||
import type { MailIngestAction } from '../../api/mailIngest';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { mailIngestRepo } from '../../repo/mailIngestRepo';
|
||||
import { tripRepo } from '../../repo/tripRepo';
|
||||
import { useMailIngestStore } from '../../store/mailIngestStore';
|
||||
import { useToast } from '../shared/Toast';
|
||||
import { actionsOf, type InboxAction } from './mailInboxModel';
|
||||
@@ -32,7 +30,18 @@ export function useMailInbox() {
|
||||
const toast = useToast();
|
||||
const navigate = useNavigate();
|
||||
const open = useMailInboxOpen((s) => s.open);
|
||||
const { entries, pending, nextBefore, loadingInbox, settings, loadInbox, loadSettings, act } = useMailIngestStore();
|
||||
const { entries, pending, nextBefore, loadingInbox, settings, loadInbox, loadSettings, act } = useMailIngestStore(
|
||||
useShallow((s) => ({
|
||||
entries: s.entries,
|
||||
pending: s.pending,
|
||||
nextBefore: s.nextBefore,
|
||||
loadingInbox: s.loadingInbox,
|
||||
settings: s.settings,
|
||||
loadInbox: s.loadInbox,
|
||||
loadSettings: s.loadSettings,
|
||||
act: s.act,
|
||||
}))
|
||||
);
|
||||
const [trips, setTrips] = useState<InboxTrip[]>([]);
|
||||
const [busy, setBusy] = useState<number | null>(null);
|
||||
/** The entry and the action waiting for a trip to be picked. */
|
||||
@@ -45,10 +54,17 @@ export function useMailInbox() {
|
||||
if (!open) return;
|
||||
void loadInbox();
|
||||
if (!settings) void loadSettings();
|
||||
tripsApi
|
||||
tripRepo
|
||||
.list()
|
||||
.then((d: { trips?: InboxTrip[] }) =>
|
||||
setTrips((d.trips ?? []).map(({ id, title, start_date, end_date }) => ({ id, title, start_date, end_date })))
|
||||
.then(({ trips: active }) =>
|
||||
setTrips(
|
||||
active.map(({ id, title, start_date, end_date }) => ({
|
||||
id,
|
||||
title,
|
||||
start_date: start_date ?? null,
|
||||
end_date: end_date ?? null,
|
||||
}))
|
||||
)
|
||||
)
|
||||
.catch(() => setTrips([]));
|
||||
}, [open, loadInbox, loadSettings, settings]);
|
||||
@@ -81,8 +97,6 @@ export function useMailInbox() {
|
||||
return tripId
|
||||
? run(entry, 'file', { trip_id: tripId }, t('mailInbox.filed'))
|
||||
: setPicking({ entry, action: 'file' });
|
||||
case 'readAi':
|
||||
return run(entry, 'read-ai', {}, t('mailInbox.readAgain'));
|
||||
case 'discard':
|
||||
return run(entry, 'discard', {}, t('mailInbox.discarded'));
|
||||
case 'manual':
|
||||
@@ -100,7 +114,7 @@ export function useMailInbox() {
|
||||
|
||||
const openForm = (entry: MailIngestInboxEntry, tripId: number) => {
|
||||
closeMailInbox();
|
||||
navigate(`/trips/${tripId}?mailPrefill=${entry.id}`);
|
||||
void navigate(`/trips/${tripId}?mailPrefill=${entry.id}`);
|
||||
};
|
||||
|
||||
const fillIn = (entry: MailIngestInboxEntry) => {
|
||||
@@ -111,13 +125,12 @@ export function useMailInbox() {
|
||||
|
||||
const showMail = async (entry: MailIngestInboxEntry) => {
|
||||
try {
|
||||
setPreview(mailIngestMessagePreviewResponseSchema.parse(await mailIngestApi.preview(entry.message_id)));
|
||||
setPreview(await mailIngestRepo.preview(entry.message_id));
|
||||
} catch {
|
||||
toast.error(t('mailInbox.previewError'));
|
||||
}
|
||||
};
|
||||
|
||||
const aiAvailable = !!settings?.ai_available && !!settings.prefs.ai_enabled;
|
||||
return {
|
||||
open,
|
||||
close: closeMailInbox,
|
||||
@@ -128,7 +141,7 @@ export function useMailInbox() {
|
||||
loading: loadingInbox,
|
||||
trips,
|
||||
busy,
|
||||
actionsOf: (entry: MailIngestInboxEntry) => actionsOf(entry, aiAvailable),
|
||||
actionsOf,
|
||||
perform: (entry: MailIngestInboxEntry, action: InboxAction) => void perform(entry, action),
|
||||
picking,
|
||||
pick,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useLocation, useNavigate } from 'react-router';
|
||||
import { openMailInbox } from './mailInboxOpener';
|
||||
|
||||
/** The query a link uses to open the inbox, e.g. the "bookings waiting" notification's `/dashboard?inbox=mail`. */
|
||||
const INBOX_PARAM = 'inbox';
|
||||
const INBOX_MAIL = 'mail';
|
||||
|
||||
/**
|
||||
* Opens the inbox of forwarded bookings when the address asks for it, then
|
||||
* takes the query off again so a reload or the back button does not reopen
|
||||
* it. Mounted where the inbox itself is mounted: the Navbar on the desktop,
|
||||
* MMailInboxHost on the phone.
|
||||
*/
|
||||
export function useMailInboxLink(enabled: boolean): void {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
useEffect(() => {
|
||||
if (!enabled) return;
|
||||
const params = new URLSearchParams(location.search);
|
||||
if (params.get(INBOX_PARAM) !== INBOX_MAIL) return;
|
||||
openMailInbox();
|
||||
params.delete(INBOX_PARAM);
|
||||
const search = params.toString();
|
||||
void navigate(
|
||||
{ pathname: location.pathname, search: search ? `?${search}` : '', hash: location.hash },
|
||||
{ replace: true }
|
||||
);
|
||||
}, [enabled, location.pathname, location.search, location.hash, navigate]);
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
import {
|
||||
isTransportReservationType,
|
||||
mailIngestPrefillResponseSchema,
|
||||
type BookingImportPreviewItem,
|
||||
} from '@trek/shared';
|
||||
import { isTransportReservationType, type BookingImportPreviewItem } from '@trek/shared';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import type { SetURLSearchParams } from 'react-router';
|
||||
import { mailIngestApi } from '../../api/mailIngest';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { mailIngestRepo } from '../../repo/mailIngestRepo';
|
||||
import { useToast } from '../shared/Toast';
|
||||
|
||||
/**
|
||||
* "Fill in yourself" from the mail inbox lands in the trip as ?mailPrefill=<id>:
|
||||
@@ -25,6 +23,8 @@ export function useMailPrefillLink({
|
||||
loaded: boolean;
|
||||
startImportReview: (items: BookingImportPreviewItem[], files?: File[], kind?: 'transports' | 'bookings') => void;
|
||||
}): void {
|
||||
const { t } = useTranslation();
|
||||
const toast = useToast();
|
||||
const requested = searchParams.get('mailPrefill');
|
||||
const handled = useRef<string | null>(null);
|
||||
|
||||
@@ -41,14 +41,14 @@ export function useMailPrefillLink({
|
||||
);
|
||||
const id = Number(requested);
|
||||
if (!Number.isInteger(id) || id <= 0) return;
|
||||
mailIngestApi
|
||||
mailIngestRepo
|
||||
.prefill(id)
|
||||
.then((raw) => {
|
||||
const { item } = mailIngestPrefillResponseSchema.parse(raw);
|
||||
.then(({ item }) => {
|
||||
startImportReview([item], [], isTransportReservationType(item.type) ? 'transports' : 'bookings');
|
||||
})
|
||||
.catch(() => {
|
||||
// An entry decided meanwhile has nothing to prefill; the trip simply stays open.
|
||||
// An entry decided meanwhile has nothing to prefill: the trip stays open, and the person hears why.
|
||||
toast.error(t('mailInbox.actionError'));
|
||||
});
|
||||
}, [requested, loaded, setSearchParams, startImportReview]);
|
||||
}, [requested, loaded, setSearchParams, startImportReview, t, toast]);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ const KIND_BY_TITLE: Record<string, NotificationKind> = {
|
||||
'notif.flight_departed.title': 'flight',
|
||||
'notif.flight_delayed.title': 'flight',
|
||||
'notif.flight_landed.title': 'flight',
|
||||
'notif.mail_booking_added.title': 'booking',
|
||||
'notif.mail_booking_pending.title': 'booking',
|
||||
'notif.mail_ingest_paused.title': 'alert',
|
||||
'notif.packing_tagged.title': 'packing',
|
||||
'notif.todo_due.title': 'todo',
|
||||
'notif.vacay_invite.title': 'vacay',
|
||||
|
||||
@@ -110,6 +110,15 @@ export default function BookingDetailDialog(p: BookingDetailDialogProps) {
|
||||
if (await copyText(r.confirmation_number || '')) toast.success(t('common.copied'))
|
||||
else toast.error(t('reservations.copyFailed'))
|
||||
}
|
||||
// "Looks right": the person checked what an import could not read for sure.
|
||||
const confirmReview = async () => {
|
||||
try {
|
||||
await updateReservation(p.tripId, r.id, { needs_review: 0 })
|
||||
toast.success(t('reservations.reviewConfirmed'))
|
||||
} catch {
|
||||
toast.error(t('reservations.toast.updateError'))
|
||||
}
|
||||
}
|
||||
const rename = async () => {
|
||||
const title = name.trim()
|
||||
setRenaming(false)
|
||||
@@ -143,7 +152,7 @@ export default function BookingDetailDialog(p: BookingDetailDialogProps) {
|
||||
{facts.day.date && !facts.isHotel && <span className="font-medium text-content-muted">{facts.day.date}</span>}
|
||||
</span>
|
||||
)}
|
||||
{!!r.needs_review && <ReviewPill pill />}
|
||||
{!!r.needs_review && <ReviewPill pill onConfirm={p.canEdit ? () => void confirmReview() : undefined} />}
|
||||
<AirTrailPill r={r} pill />
|
||||
<MailPill r={r} pill />
|
||||
{r.confirmation_number && (
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// FE-PLANNER-BKPARTS-001 to FE-PLANNER-BKPARTS-004
|
||||
// FE-PLANNER-BKPARTS-001 to FE-PLANNER-BKPARTS-005
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { buildTripFile } from '../../../../tests/helpers/factories';
|
||||
import { downloadFile, openFile } from '../../../utils/fileDownload';
|
||||
import type { BookingFacts } from './bookingFacts';
|
||||
import { FileRows, WhenFields } from './bookingParts';
|
||||
import { FileRows, ReviewPill, WhenFields } from './bookingParts';
|
||||
|
||||
vi.mock('../../../utils/fileDownload', () => ({
|
||||
openFile: vi.fn(() => Promise.resolve()),
|
||||
@@ -88,4 +88,13 @@ describe('FileRows', () => {
|
||||
const { container } = render(<FileRows files={[]} />);
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
|
||||
it('FE-PLANNER-BKPARTS-005: the review pill takes its mark off only for someone who may edit', () => {
|
||||
const onConfirm = vi.fn();
|
||||
const { rerender } = render(<ReviewPill pill />);
|
||||
expect(screen.queryByRole('button')).not.toBeInTheDocument();
|
||||
rerender(<ReviewPill pill onConfirm={onConfirm} />);
|
||||
fireEvent.click(screen.getByRole('button'));
|
||||
expect(onConfirm).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -167,15 +167,33 @@ export function TypeTile({ type, size = 32, raised = false }: { type: string; si
|
||||
)
|
||||
}
|
||||
|
||||
/** The warning icon beside a booking's name on a card or row, or with `pill` a header pill in the detail dialog. */
|
||||
export function ReviewPill({ pill = false }: { pill?: boolean }) {
|
||||
/**
|
||||
* The warning icon beside a booking's name on a card or row, or with `pill` a
|
||||
* header pill in the detail dialog. With `onConfirm` (the right to edit) the
|
||||
* pill is the "looks right" switch that takes the mark off.
|
||||
*/
|
||||
export function ReviewPill({ pill = false, onConfirm }: { pill?: boolean; onConfirm?: () => void }) {
|
||||
const { t } = useTranslation()
|
||||
const content = (
|
||||
<>
|
||||
<AlertCircle size={13} strokeWidth={2.2} className="text-warning" />
|
||||
{t('reservations.needsReview')}
|
||||
</>
|
||||
)
|
||||
if (pill && onConfirm) {
|
||||
return (
|
||||
<Tooltip label={`${t('reservations.needsReviewHint')} ${t('reservations.reviewConfirmHint')}`}>
|
||||
<button type="button" onClick={onConfirm} aria-label={t('reservations.reviewConfirm')} className={`${PILL} hover:opacity-80`} style={fs(12, 'body')}>
|
||||
{content}
|
||||
</button>
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Tooltip label={t('reservations.needsReviewHint')}>
|
||||
{pill ? (
|
||||
<span className={PILL} style={fs(12, 'body')}>
|
||||
<AlertCircle size={13} strokeWidth={2.2} className="text-warning" />
|
||||
{t('reservations.needsReview')}
|
||||
{content}
|
||||
</span>
|
||||
) : (
|
||||
<span role="img" aria-label={t('reservations.needsReview')} className="grid flex-none place-items-center text-warning">
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import type { Reservation } from '../../../types';
|
||||
import type { DelayTone } from '../../../utils/flightLiveModel';
|
||||
import { BOX, Eyebrow } from '../bookings/bookingParts';
|
||||
import { useCurrentFlightLegIndex, useFlightLiveCard } from './useFlightLiveCard';
|
||||
|
||||
const DELAY_TEXT: Record<DelayTone, string> = { ok: 'text-success', minor: 'text-warning', major: 'text-danger' };
|
||||
@@ -13,8 +15,9 @@ interface FlightLiveStripProps {
|
||||
}
|
||||
|
||||
/**
|
||||
* A flight's live state on the booking cards: what is happening in one line
|
||||
* with the delay, and a thin bar across the card while it flies. The full
|
||||
* A flight's live state on the booking cards, as one of the card's fields:
|
||||
* what is happening in one line with the delay, and a thin bar along the
|
||||
* field's foot while it flies. The full
|
||||
* picture is one click away in the booking dialog. Nothing far ahead of the
|
||||
* flight (the card shows its date already), nothing once it is long over.
|
||||
*/
|
||||
@@ -30,30 +33,30 @@ function Strip({
|
||||
legIndex,
|
||||
className,
|
||||
}: Omit<FlightLiveStripProps, 'type'> & { legIndex: number }) {
|
||||
const { t } = useTranslation();
|
||||
const card = useFlightLiveCard(tripId, reservationId, legIndex);
|
||||
if (!card || card.view.stage === 'upcoming') return null;
|
||||
const { view } = card;
|
||||
// The card's own field: the eyebrow over a framed value, like the booking code and the route under it.
|
||||
return (
|
||||
<div className={`flex min-w-0 flex-col gap-1.5 rounded-lg bg-surface-tertiary px-2.5 py-[7px] ${className}`}>
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<span className="min-w-0 flex-1 truncate text-caption font-semibold text-content">{card.line}</span>
|
||||
{card.delay && card.delay.tone !== 'ok' && (
|
||||
<span className={`flex-none text-caption font-semibold tabular-nums ${DELAY_TEXT[card.delay.tone]}`}>
|
||||
{card.delay.text}
|
||||
<div className={`min-w-0 ${className}`}>
|
||||
<Eyebrow className="mb-[3px]">{t('reservations.status')}</Eyebrow>
|
||||
<div className={`${BOX} relative overflow-hidden px-[10px] py-[7px]`}>
|
||||
<div className="flex min-w-0 items-center justify-center gap-2 text-body font-semibold text-content">
|
||||
<span className="min-w-0 truncate">{card.line}</span>
|
||||
{card.delay && card.delay.tone !== 'ok' && (
|
||||
<span className={`flex-none tabular-nums ${DELAY_TEXT[card.delay.tone]}`}>{card.delay.text}</span>
|
||||
)}
|
||||
</div>
|
||||
{view.stage === 'airborne' && (
|
||||
<span className="absolute inset-x-0 bottom-0 block h-[3px] bg-surface-tertiary" aria-hidden="true">
|
||||
<span
|
||||
className="block h-full bg-info transition-[width] duration-700 motion-reduce:transition-none"
|
||||
style={{ width: `${Math.round(view.progress * 100)}%` }}
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{view.stage === 'airborne' && (
|
||||
<span
|
||||
className="block h-1 w-full overflow-hidden rounded-full bg-[color:var(--border-primary)]"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<span
|
||||
className="block h-full rounded-full bg-accent transition-[width] duration-700 motion-reduce:transition-none"
|
||||
style={{ width: `${Math.round(view.progress * 100)}%` }}
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -90,3 +90,14 @@
|
||||
.flight-mini-map .leaflet-tooltip.flight-mini-code::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* A map kept to the middle of its pass (the phone): the edges still run out,
|
||||
but the route fills most of it instead of a third. */
|
||||
.flight-mini-map.flight-mini-map--narrow {
|
||||
-webkit-mask-image:
|
||||
linear-gradient(to right, transparent, #000 16%, #000 84%, transparent),
|
||||
linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
|
||||
mask-image:
|
||||
linear-gradient(to right, transparent, #000 16%, #000 84%, transparent),
|
||||
linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ export const EVENT_LABEL_KEYS: Record<string, string> = {
|
||||
flight_departed: 'settings.notifyFlightDeparted',
|
||||
flight_delayed: 'settings.notifyFlightDelayed',
|
||||
flight_landed: 'settings.notifyFlightLanded',
|
||||
mail_booking_added: 'settings.notifyMailBookingAdded',
|
||||
mail_booking_pending: 'settings.notifyMailBookingPending',
|
||||
mail_ingest_paused: 'settings.notifyMailIngestPaused',
|
||||
}
|
||||
|
||||
/** Plugin channels have no i18n; the server sends their display name outright. */
|
||||
|
||||
Reference in New Issue
Block a user