mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 13:23:04 +00:00
fix(mail-ingest): type errors and formatting after joining the flight work
The cron callbacks hand back nothing; the cursor's lookup is findCursor so it no longer shadows the base repository's find(); the draft's suggested trip uses the shared contract's type; endpoints spell out their optional columns; the relay page's running count is typed. Prettier over every new file outside the generated entities.
This commit is contained in:
@@ -24,7 +24,8 @@ export const mailIngestApi = {
|
||||
inbox: (params: { status?: 'open' | 'resolved'; before?: number; limit?: number }): Promise<unknown> =>
|
||||
apiClient.get('/mail-ingest/inbox', { params }).then(data),
|
||||
inboxCount: (): Promise<unknown> => apiClient.get('/mail-ingest/inbox/count').then(data),
|
||||
preview: (messageId: number): Promise<unknown> => apiClient.get(`/mail-ingest/messages/${messageId}/preview`).then(data),
|
||||
preview: (messageId: number): Promise<unknown> =>
|
||||
apiClient.get(`/mail-ingest/messages/${messageId}/preview`).then(data),
|
||||
prefill: (candidateId: number): Promise<unknown> =>
|
||||
apiClient.get(`/mail-ingest/candidates/${candidateId}/prefill`).then(data),
|
||||
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
import { useId, type ReactElement } from 'react';
|
||||
import { Copy, FilePlus2, FileText, Inbox, Loader2, Mail, PencilLine, Plus, Sparkles, Trash2 } from 'lucide-react';
|
||||
import type { MailIngestInboxEntry } from '@trek/shared';
|
||||
import { Copy, FilePlus2, FileText, Inbox, Loader2, Mail, PencilLine, Plus, Sparkles, Trash2 } from 'lucide-react';
|
||||
import { useId, type ReactElement } from 'react';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { copyText } from '../../utils/clipboard';
|
||||
import { formatDate } from '../../utils/formatters';
|
||||
import { RES_ICONS } from '../Planner/DayPlanSidebar.constants';
|
||||
import { DialogButton, DialogHeader, DialogIconButton, DialogShell, DialogTile, NEUTRAL_TINT } from '../shared/DialogShell';
|
||||
import {
|
||||
DialogButton,
|
||||
DialogHeader,
|
||||
DialogIconButton,
|
||||
DialogShell,
|
||||
DialogTile,
|
||||
NEUTRAL_TINT,
|
||||
} from '../shared/DialogShell';
|
||||
import { useToast } from '../shared/Toast';
|
||||
import { entryDates, entryTitle, reasonText, type InboxAction } from './mailInboxModel';
|
||||
import { useMailInbox, type InboxTrip } from './useMailInbox';
|
||||
@@ -46,7 +53,9 @@ function Entry({ entry, inbox }: { entry: MailIngestInboxEntry; inbox: ReturnTyp
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex min-w-0 items-baseline gap-2">
|
||||
<span dir="auto" className="min-w-0 truncate text-body font-semibold text-content">{title}</span>
|
||||
<span dir="auto" className="min-w-0 truncate text-body font-semibold text-content">
|
||||
{title}
|
||||
</span>
|
||||
{dates && (
|
||||
<span className="flex-none text-caption tabular-nums text-content-muted">
|
||||
{formatDate(dates.start, locale)}
|
||||
@@ -57,7 +66,10 @@ function Entry({ entry, inbox }: { entry: MailIngestInboxEntry; inbox: ReturnTyp
|
||||
{reason && <div className="mt-0.5 text-caption text-warning">{reasonText(reason, t)}</div>}
|
||||
{code && (
|
||||
<div className="mt-2 flex items-center gap-2">
|
||||
<code dir="ltr" className="rounded-lg bg-surface-tertiary px-2.5 py-1 font-geist text-subtitle font-semibold tracking-[0.08em] text-content">
|
||||
<code
|
||||
dir="ltr"
|
||||
className="rounded-lg bg-surface-tertiary px-2.5 py-1 font-geist text-subtitle font-semibold tracking-[0.08em] text-content"
|
||||
>
|
||||
{code}
|
||||
</code>
|
||||
<DialogIconButton
|
||||
@@ -71,9 +83,15 @@ function Entry({ entry, inbox }: { entry: MailIngestInboxEntry; inbox: ReturnTyp
|
||||
)}
|
||||
<div className="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-caption text-content-faint">
|
||||
{entry.suggested_trip && (
|
||||
<span className="rounded-full bg-surface-tertiary px-2 py-0.5 font-medium text-content-secondary">{entry.suggested_trip.title}</span>
|
||||
<span className="rounded-full bg-surface-tertiary px-2 py-0.5 font-medium text-content-secondary">
|
||||
{entry.suggested_trip.title}
|
||||
</span>
|
||||
)}
|
||||
<button type="button" onClick={() => inbox.showMail(entry)} className="inline-flex items-center gap-1 hover:text-content">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => inbox.showMail(entry)}
|
||||
className="inline-flex items-center gap-1 hover:text-content"
|
||||
>
|
||||
<FileText size={12} strokeWidth={2} />
|
||||
{t('mailInbox.showMail')}
|
||||
</button>
|
||||
@@ -83,22 +101,50 @@ function Entry({ entry, inbox }: { entry: MailIngestInboxEntry; inbox: ReturnTyp
|
||||
{busy && <Loader2 size={16} strokeWidth={2} className="mt-2 animate-spin text-content-faint" />}
|
||||
{rest.map((action) => {
|
||||
const look = actionLook(action, t);
|
||||
return <DialogIconButton key={action} label={look.label} icon={look.icon} danger={action === 'discard'} disabled={busy} onClick={() => inbox.perform(entry, action)} />;
|
||||
return (
|
||||
<DialogIconButton
|
||||
key={action}
|
||||
label={look.label}
|
||||
icon={look.icon}
|
||||
danger={action === 'discard'}
|
||||
disabled={busy}
|
||||
onClick={() => inbox.perform(entry, action)}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{primary && primary !== 'discard' && (
|
||||
<DialogButton variant="primary" icon={actionLook(primary, t).icon} disabled={busy} onClick={() => inbox.perform(entry, primary)}>
|
||||
<DialogButton
|
||||
variant="primary"
|
||||
icon={actionLook(primary, t).icon}
|
||||
disabled={busy}
|
||||
onClick={() => inbox.perform(entry, primary)}
|
||||
>
|
||||
{actionLook(primary, t).label}
|
||||
</DialogButton>
|
||||
)}
|
||||
{primary === 'discard' && (
|
||||
<DialogIconButton label={actionLook('discard', t).label} icon={actionLook('discard', t).icon} danger disabled={busy} onClick={() => inbox.perform(entry, 'discard')} />
|
||||
<DialogIconButton
|
||||
label={actionLook('discard', t).label}
|
||||
icon={actionLook('discard', t).icon}
|
||||
danger
|
||||
disabled={busy}
|
||||
onClick={() => inbox.perform(entry, 'discard')}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
function TripPicker({ trips, onPick, onCancel }: { trips: InboxTrip[]; onPick: (id: number) => void; onCancel: () => void }) {
|
||||
function TripPicker({
|
||||
trips,
|
||||
onPick,
|
||||
onCancel,
|
||||
}: {
|
||||
trips: InboxTrip[];
|
||||
onPick: (id: number) => void;
|
||||
onCancel: () => void;
|
||||
}) {
|
||||
const { t, locale } = useTranslation();
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
@@ -106,9 +152,19 @@ function TripPicker({ trips, onPick, onCancel }: { trips: InboxTrip[]; onPick: (
|
||||
<ul className="flex max-h-[50vh] flex-col gap-1.5 overflow-y-auto">
|
||||
{trips.map((trip) => (
|
||||
<li key={trip.id}>
|
||||
<button type="button" onClick={() => onPick(trip.id)} className="flex w-full items-baseline justify-between gap-3 rounded-lg bg-surface-tertiary px-3 py-2.5 text-start hover:bg-surface-hover">
|
||||
<span dir="auto" className="min-w-0 truncate text-body font-medium text-content">{trip.title}</span>
|
||||
{trip.start_date && <span className="flex-none text-caption tabular-nums text-content-muted">{formatDate(trip.start_date, locale)}</span>}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onPick(trip.id)}
|
||||
className="flex w-full items-baseline justify-between gap-3 rounded-lg bg-surface-tertiary px-3 py-2.5 text-start hover:bg-surface-hover"
|
||||
>
|
||||
<span dir="auto" className="min-w-0 truncate text-body font-medium text-content">
|
||||
{trip.title}
|
||||
</span>
|
||||
{trip.start_date && (
|
||||
<span className="flex-none text-caption tabular-nums text-content-muted">
|
||||
{formatDate(trip.start_date, locale)}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
@@ -135,7 +191,11 @@ export default function MailInboxDialog(): ReactElement | null {
|
||||
|
||||
const header = (
|
||||
<DialogHeader
|
||||
tile={<DialogTile><Inbox size={18} strokeWidth={2} /></DialogTile>}
|
||||
tile={
|
||||
<DialogTile>
|
||||
<Inbox size={18} strokeWidth={2} />
|
||||
</DialogTile>
|
||||
}
|
||||
tint={NEUTRAL_TINT}
|
||||
labelId={titleId}
|
||||
onClose={inbox.close}
|
||||
@@ -145,13 +205,22 @@ export default function MailInboxDialog(): ReactElement | null {
|
||||
);
|
||||
|
||||
return (
|
||||
<DialogShell onClose={inbox.close} labelledBy={titleId} width="editor" align="top" header={header} blocked={!!inbox.picking}>
|
||||
<DialogShell
|
||||
onClose={inbox.close}
|
||||
labelledBy={titleId}
|
||||
width="editor"
|
||||
align="top"
|
||||
header={header}
|
||||
blocked={!!inbox.picking}
|
||||
>
|
||||
{inbox.picking ? (
|
||||
<TripPicker trips={inbox.trips} onPick={inbox.pick} onCancel={inbox.cancelPick} />
|
||||
) : inbox.preview ? (
|
||||
<div className="flex flex-col gap-3">
|
||||
<div className="text-body font-semibold text-content">{inbox.preview.subject ?? t('mailInbox.untitled')}</div>
|
||||
<pre className="max-h-[55vh] overflow-auto whitespace-pre-wrap rounded-lg bg-surface-tertiary p-3 font-geist text-caption text-content-secondary">{inbox.preview.text}</pre>
|
||||
<pre className="max-h-[55vh] overflow-auto whitespace-pre-wrap rounded-lg bg-surface-tertiary p-3 font-geist text-caption text-content-secondary">
|
||||
{inbox.preview.text}
|
||||
</pre>
|
||||
<div>
|
||||
<DialogButton onClick={inbox.closePreview}>{t('mailInbox.backToList')}</DialogButton>
|
||||
</div>
|
||||
@@ -164,10 +233,14 @@ export default function MailInboxDialog(): ReactElement | null {
|
||||
</div>
|
||||
) : (
|
||||
<ul className="flex flex-col gap-2">
|
||||
{inbox.entries.map((entry) => <Entry key={entry.id} entry={entry} inbox={inbox} />)}
|
||||
{inbox.entries.map((entry) => (
|
||||
<Entry key={entry.id} entry={entry} inbox={inbox} />
|
||||
))}
|
||||
{inbox.hasMore && (
|
||||
<li className="flex justify-center pt-1">
|
||||
<DialogButton onClick={inbox.loadMore} disabled={inbox.loading}>{t('mailInbox.loadMore')}</DialogButton>
|
||||
<DialogButton onClick={inbox.loadMore} disabled={inbox.loading}>
|
||||
{t('mailInbox.loadMore')}
|
||||
</DialogButton>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { mailIngestAddressResponseSchema, type MailIngestAddress } from '@trek/shared';
|
||||
import { useEffect, useState, type ReactElement } from 'react';
|
||||
import { Copy, Mail, Plus } from 'lucide-react';
|
||||
import { useEffect, useState, type ReactElement } from 'react';
|
||||
import { mailIngestApi } from '../../api/mailIngest';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { useMailIngestStore } from '../../store/mailIngestStore';
|
||||
@@ -68,7 +68,10 @@ export default function TripMailForward({ tripId }: { tripId: number }): ReactEl
|
||||
<div className="text-caption text-content-muted">{t('mailInbox.trip.hint')}</div>
|
||||
{address ? (
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<code dir="ltr" className="min-w-0 flex-1 truncate rounded-lg bg-surface-card px-2.5 py-1.5 font-geist text-caption text-content">
|
||||
<code
|
||||
dir="ltr"
|
||||
className="min-w-0 flex-1 truncate rounded-lg bg-surface-card px-2.5 py-1.5 font-geist text-caption text-content"
|
||||
>
|
||||
{address.address}
|
||||
</code>
|
||||
<button
|
||||
|
||||
@@ -5,7 +5,10 @@ import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { actionsOf, canUndo, entryDates, entryTitle, reasonText } from './mailInboxModel';
|
||||
|
||||
function entry(over: Partial<MailIngestInboxEntry> = {}, message: Partial<MailIngestInboxEntry['message']> = {}): MailIngestInboxEntry {
|
||||
function entry(
|
||||
over: Partial<MailIngestInboxEntry> = {},
|
||||
message: Partial<MailIngestInboxEntry['message']> = {}
|
||||
): MailIngestInboxEntry {
|
||||
return {
|
||||
id: 1,
|
||||
message_id: 10,
|
||||
@@ -57,13 +60,21 @@ describe('mailInboxModel', () => {
|
||||
});
|
||||
|
||||
it('FE-MAILINBOX-MODEL-003: a mail without a booking offers the document, the form, and AI only where it can help', () => {
|
||||
const none = entry({ item: null, reason: 'not_a_booking' }, { attachments: [{ file_name: 'invoice.pdf', kind: 'pdf', size: 1 }] });
|
||||
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']);
|
||||
});
|
||||
|
||||
it('FE-MAILINBOX-MODEL-004: a forwarding confirmation or a newsletter only informs', () => {
|
||||
expect(actionsOf(entry({ item: null, reason: null }, { reason: 'forwarding_confirmation', forwarding_code: '123456' }), true)).toEqual(['discard']);
|
||||
expect(
|
||||
actionsOf(
|
||||
entry({ item: null, reason: null }, { reason: 'forwarding_confirmation', forwarding_code: '123456' }),
|
||||
true
|
||||
)
|
||||
).toEqual(['discard']);
|
||||
});
|
||||
|
||||
it('FE-MAILINBOX-MODEL-005: every reason has its words, and title and dates come from the booking', () => {
|
||||
|
||||
@@ -11,7 +11,14 @@ import type { MailIngestInboxEntry, MailIngestReason } from '@trek/shared';
|
||||
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']);
|
||||
const AI_RETRY: ReadonlySet<MailIngestReason> = new Set([
|
||||
'ai_quota_exhausted',
|
||||
'ai_user_cap',
|
||||
'ai_provider_error',
|
||||
'ai_disabled',
|
||||
'not_a_booking',
|
||||
'mail_unreadable',
|
||||
]);
|
||||
|
||||
/** Reasons that need no booking decision at all: the entry only informs. */
|
||||
const INFO_ONLY: ReadonlySet<MailIngestReason> = new Set(['forwarding_confirmation', 'newsletter', 'auto_reply']);
|
||||
@@ -119,5 +126,9 @@ export function entryDates(entry: MailIngestInboxEntry): { start: string; end: s
|
||||
|
||||
/** True while an added booking can still be taken back in one tap. */
|
||||
export function canUndo(entry: { undo_until: string | null; resolution: string }, now: number): boolean {
|
||||
return (entry.resolution === 'applied' || entry.resolution === 'auto_applied') && !!entry.undo_until && Date.parse(entry.undo_until) > now;
|
||||
return (
|
||||
(entry.resolution === 'applied' || entry.resolution === 'auto_applied') &&
|
||||
!!entry.undo_until &&
|
||||
Date.parse(entry.undo_until) > now
|
||||
);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ export function useMailImportSettings() {
|
||||
setSaving(key);
|
||||
try {
|
||||
const parsed = mailIngestSettingsResponseSchema.parse(
|
||||
await mailIngestApi.updateSettings({ [key]: !settings.prefs[key] }),
|
||||
await mailIngestApi.updateSettings({ [key]: !settings.prefs[key] })
|
||||
);
|
||||
setSettings(parsed);
|
||||
} catch {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { mailIngestMessagePreviewResponseSchema, type MailIngestInboxEntry, type MailIngestMessagePreviewResponse } from '@trek/shared';
|
||||
import {
|
||||
mailIngestMessagePreviewResponseSchema,
|
||||
type MailIngestInboxEntry,
|
||||
type MailIngestMessagePreviewResponse,
|
||||
} from '@trek/shared';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { tripsApi } from '../../api/client';
|
||||
@@ -6,8 +10,8 @@ import { mailIngestApi, type MailIngestAction } from '../../api/mailIngest';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { useMailIngestStore } from '../../store/mailIngestStore';
|
||||
import { useToast } from '../shared/Toast';
|
||||
import { closeMailInbox, useMailInboxOpen } from './mailInboxOpener';
|
||||
import { actionsOf, type InboxAction } from './mailInboxModel';
|
||||
import { closeMailInbox, useMailInboxOpen } from './mailInboxOpener';
|
||||
|
||||
export interface InboxTrip {
|
||||
id: number;
|
||||
@@ -32,7 +36,9 @@ export function useMailInbox() {
|
||||
const [trips, setTrips] = useState<InboxTrip[]>([]);
|
||||
const [busy, setBusy] = useState<number | null>(null);
|
||||
/** The entry and the action waiting for a trip to be picked. */
|
||||
const [picking, setPicking] = useState<{ entry: MailIngestInboxEntry; action: 'apply' | 'file' | 'manual' } | null>(null);
|
||||
const [picking, setPicking] = useState<{ entry: MailIngestInboxEntry; action: 'apply' | 'file' | 'manual' } | null>(
|
||||
null
|
||||
);
|
||||
const [preview, setPreview] = useState<MailIngestMessagePreviewResponse | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -41,11 +47,18 @@ export function useMailInbox() {
|
||||
if (!settings) void loadSettings();
|
||||
tripsApi
|
||||
.list()
|
||||
.then((d: { trips?: InboxTrip[] }) => setTrips((d.trips ?? []).map(({ id, title, start_date, end_date }) => ({ id, title, start_date, end_date }))))
|
||||
.then((d: { trips?: InboxTrip[] }) =>
|
||||
setTrips((d.trips ?? []).map(({ id, title, start_date, end_date }) => ({ id, title, start_date, end_date })))
|
||||
)
|
||||
.catch(() => setTrips([]));
|
||||
}, [open, loadInbox, loadSettings, settings]);
|
||||
|
||||
const run = async (entry: MailIngestInboxEntry, action: MailIngestAction, body: Record<string, unknown>, done: string) => {
|
||||
const run = async (
|
||||
entry: MailIngestInboxEntry,
|
||||
action: MailIngestAction,
|
||||
body: Record<string, unknown>,
|
||||
done: string
|
||||
) => {
|
||||
setBusy(entry.id);
|
||||
try {
|
||||
await act(entry.id, action, body);
|
||||
@@ -65,7 +78,9 @@ export function useMailInbox() {
|
||||
case 'choose':
|
||||
return setPicking({ entry, action: 'apply' });
|
||||
case 'file':
|
||||
return tripId ? run(entry, 'file', { trip_id: tripId }, t('mailInbox.filed')) : setPicking({ entry, action: 'file' });
|
||||
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':
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { isTransportReservationType, mailIngestPrefillResponseSchema, type BookingImportPreviewItem } from '@trek/shared';
|
||||
import {
|
||||
isTransportReservationType,
|
||||
mailIngestPrefillResponseSchema,
|
||||
type BookingImportPreviewItem,
|
||||
} from '@trek/shared';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import type { SetURLSearchParams } from 'react-router';
|
||||
import { mailIngestApi } from '../../api/mailIngest';
|
||||
@@ -33,7 +37,7 @@ export function useMailPrefillLink({
|
||||
next.delete('mailPrefill');
|
||||
return next;
|
||||
},
|
||||
{ replace: true },
|
||||
{ replace: true }
|
||||
);
|
||||
const id = Number(requested);
|
||||
if (!Number.isInteger(id) || id <= 0) return;
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
import { useRef, type ReactElement } from 'react';
|
||||
import { ChevronRight, Copy, FileUp, Inbox, Loader2, Mail, RefreshCw } from 'lucide-react';
|
||||
import { useRef, type ReactElement } from 'react';
|
||||
import { useTranslation } from '../../i18n';
|
||||
import { useMailImportSettings } from '../MailIngest/useMailImportSettings';
|
||||
import { openMailInbox } from '../MailIngest/mailInboxOpener';
|
||||
import { useMailImportSettings } from '../MailIngest/useMailImportSettings';
|
||||
import { Tooltip } from '../shared/Tooltip';
|
||||
import Section from './Section';
|
||||
import ToggleSwitch from './ToggleSwitch';
|
||||
import { SETTINGS_BUTTON, SETTINGS_ICON_BUTTON, SettingRow, SettingRows, SettingsHint, StatusPill } from './settingsKit';
|
||||
import {
|
||||
SETTINGS_BUTTON,
|
||||
SETTINGS_ICON_BUTTON,
|
||||
SettingRow,
|
||||
SettingRows,
|
||||
SettingsHint,
|
||||
StatusPill,
|
||||
} from './settingsKit';
|
||||
|
||||
/**
|
||||
* Settings → Integrations → Booking mail import: the person's forwarding
|
||||
@@ -26,7 +33,10 @@ export default function MailImportSection(): ReactElement | null {
|
||||
title={t('mailInbox.settings.title')}
|
||||
icon={Mail}
|
||||
badge={
|
||||
<StatusPill tone={prefs.enabled ? 'success' : 'neutral'} icon={<span className="h-1.5 w-1.5 rounded-full bg-current" />}>
|
||||
<StatusPill
|
||||
tone={prefs.enabled ? 'success' : 'neutral'}
|
||||
icon={<span className="h-1.5 w-1.5 rounded-full bg-current" />}
|
||||
>
|
||||
{prefs.enabled ? t('mailInbox.settings.on') : t('mailInbox.settings.off')}
|
||||
</StatusPill>
|
||||
}
|
||||
@@ -44,7 +54,12 @@ export default function MailImportSection(): ReactElement | null {
|
||||
{address.address}
|
||||
</code>
|
||||
<Tooltip label={t('mailInbox.settings.copy')}>
|
||||
<button type="button" onClick={() => void s.copyAddress()} aria-label={t('mailInbox.settings.copy')} className={SETTINGS_ICON_BUTTON}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void s.copyAddress()}
|
||||
aria-label={t('mailInbox.settings.copy')}
|
||||
className={SETTINGS_ICON_BUTTON}
|
||||
>
|
||||
<Copy size={14} strokeWidth={2} />
|
||||
</button>
|
||||
</Tooltip>
|
||||
@@ -63,7 +78,11 @@ export default function MailImportSection(): ReactElement | null {
|
||||
<SettingsHint>{t('mailInbox.settings.addressHint')}</SettingsHint>
|
||||
<details className="group rounded-lg bg-surface-tertiary px-3 py-2 text-body text-content-secondary">
|
||||
<summary className="flex cursor-pointer list-none items-center gap-1.5 font-medium text-content">
|
||||
<ChevronRight size={14} strokeWidth={2} className="transition-transform group-open:rotate-90 rtl:-scale-x-100" />
|
||||
<ChevronRight
|
||||
size={14}
|
||||
strokeWidth={2}
|
||||
className="transition-transform group-open:rotate-90 rtl:-scale-x-100"
|
||||
/>
|
||||
{t('mailInbox.settings.howTo')}
|
||||
</summary>
|
||||
<ul className="mt-2 flex list-disc flex-col gap-1.5 ps-5 text-caption">
|
||||
@@ -79,7 +98,14 @@ export default function MailImportSection(): ReactElement | null {
|
||||
<SettingRow
|
||||
label={t('mailInbox.settings.enabled')}
|
||||
hint={t('mailInbox.settings.enabledHint')}
|
||||
control={<ToggleSwitch on={prefs.enabled} disabled={s.saving !== null} onToggle={() => void s.toggle('enabled')} label={t('mailInbox.settings.enabled')} />}
|
||||
control={
|
||||
<ToggleSwitch
|
||||
on={prefs.enabled}
|
||||
disabled={s.saving !== null}
|
||||
onToggle={() => void s.toggle('enabled')}
|
||||
label={t('mailInbox.settings.enabled')}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SettingRow
|
||||
label={t('mailInbox.settings.ai')}
|
||||
@@ -114,10 +140,23 @@ export default function MailImportSection(): ReactElement | null {
|
||||
<button type="button" onClick={openMailInbox} className={SETTINGS_BUTTON}>
|
||||
<Inbox size={14} strokeWidth={2.2} />
|
||||
{t('mailInbox.title')}
|
||||
{pending > 0 && <span className="rounded-full bg-accent px-1.5 text-caption font-semibold text-accent-text">{pending}</span>}
|
||||
{pending > 0 && (
|
||||
<span className="rounded-full bg-accent px-1.5 text-caption font-semibold text-accent-text">
|
||||
{pending}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
<button type="button" onClick={() => file.current?.click()} disabled={s.uploading} className={SETTINGS_BUTTON}>
|
||||
{s.uploading ? <Loader2 size={14} strokeWidth={2.2} className="animate-spin" /> : <FileUp size={14} strokeWidth={2.2} />}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => file.current?.click()}
|
||||
disabled={s.uploading}
|
||||
className={SETTINGS_BUTTON}
|
||||
>
|
||||
{s.uploading ? (
|
||||
<Loader2 size={14} strokeWidth={2.2} className="animate-spin" />
|
||||
) : (
|
||||
<FileUp size={14} strokeWidth={2.2} />
|
||||
)}
|
||||
{t('mailInbox.settings.upload')}
|
||||
</button>
|
||||
<input
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import type { ReactElement } from 'react';
|
||||
import { ChevronLeft, Copy, FilePlus2, FileText, Inbox, Mail, PencilLine, Plus, Sparkles, Trash2 } from 'lucide-react';
|
||||
import type { MailIngestInboxEntry } from '@trek/shared';
|
||||
import { ChevronLeft, Copy, FilePlus2, FileText, Inbox, Mail, PencilLine, Plus, Sparkles, Trash2 } from 'lucide-react';
|
||||
import type { ReactElement } from 'react';
|
||||
import { entryDates, entryTitle, reasonText, type InboxAction } from '../../../components/MailIngest/mailInboxModel';
|
||||
import { useMailInbox } from '../../../components/MailIngest/useMailInbox';
|
||||
import { RES_ICONS } from '../../../components/Planner/DayPlanSidebar.constants';
|
||||
import { useToast } from '../../../components/shared/Toast';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import { copyText } from '../../../utils/clipboard';
|
||||
import { formatDate } from '../../../utils/formatters';
|
||||
import { RES_ICONS } from '../../../components/Planner/DayPlanSidebar.constants';
|
||||
import { useToast } from '../../../components/shared/Toast';
|
||||
import { entryDates, entryTitle, reasonText, type InboxAction } from '../../../components/MailIngest/mailInboxModel';
|
||||
import { useMailInbox } from '../../../components/MailIngest/useMailInbox';
|
||||
import MSheet from '../../components/MSheet';
|
||||
import { INNER_CLS, TileHeader } from '../trip/sheets/MTripSheetUi';
|
||||
|
||||
const ROUND = 'grid h-9 w-9 flex-none place-items-center rounded-full bg-[color:var(--m-ic)] text-m-ink disabled:opacity-50';
|
||||
const ROUND =
|
||||
'grid h-9 w-9 flex-none place-items-center rounded-full bg-[color:var(--m-ic)] text-m-ink disabled:opacity-50';
|
||||
|
||||
function icon(action: InboxAction): ReactElement {
|
||||
switch (action) {
|
||||
@@ -63,14 +64,20 @@ function Entry({ entry, inbox }: { entry: MailIngestInboxEntry; inbox: ReturnTyp
|
||||
<Icon size={16} strokeWidth={2} />
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<div dir="auto" className="truncate text-body font-semibold text-m-ink">{entryTitle(entry) ?? t('mailInbox.untitled')}</div>
|
||||
<div dir="auto" className="truncate text-body font-semibold text-m-ink">
|
||||
{entryTitle(entry) ?? t('mailInbox.untitled')}
|
||||
</div>
|
||||
{dates && (
|
||||
<div className="font-geist text-caption tabular-nums text-m-muted">
|
||||
{formatDate(dates.start, locale)}
|
||||
{dates.end ? ` → ${formatDate(dates.end, locale)}` : ''}
|
||||
</div>
|
||||
)}
|
||||
{reason && <div className="mt-[2px] text-caption" style={{ color: 'var(--m-st-pending)' }}>{reasonText(reason, t)}</div>}
|
||||
{reason && (
|
||||
<div className="mt-[2px] text-caption" style={{ color: 'var(--m-st-pending)' }}>
|
||||
{reasonText(reason, t)}
|
||||
</div>
|
||||
)}
|
||||
{entry.suggested_trip && (
|
||||
<span className="mt-[6px] inline-block max-w-full truncate rounded-full bg-[color:var(--m-ic)] px-[9px] py-[2px] text-caption font-medium text-m-muted">
|
||||
{entry.suggested_trip.title}
|
||||
@@ -80,7 +87,10 @@ function Entry({ entry, inbox }: { entry: MailIngestInboxEntry; inbox: ReturnTyp
|
||||
</div>
|
||||
{code && (
|
||||
<div className="mt-[10px] flex items-center gap-2">
|
||||
<code dir="ltr" className="min-w-0 flex-1 rounded-[12px] bg-[color:var(--m-ic)] px-3 py-[8px] text-center font-geist text-subtitle font-bold tracking-[0.1em] text-m-ink">
|
||||
<code
|
||||
dir="ltr"
|
||||
className="min-w-0 flex-1 rounded-[12px] bg-[color:var(--m-ic)] px-3 py-[8px] text-center font-geist text-subtitle font-bold tracking-[0.1em] text-m-ink"
|
||||
>
|
||||
{code}
|
||||
</code>
|
||||
<button
|
||||
@@ -96,7 +106,12 @@ function Entry({ entry, inbox }: { entry: MailIngestInboxEntry; inbox: ReturnTyp
|
||||
</div>
|
||||
)}
|
||||
<div className="mt-[10px] flex items-center gap-[7px]">
|
||||
<button type="button" aria-label={t('mailInbox.showMail')} className={ROUND} onClick={() => inbox.showMail(entry)}>
|
||||
<button
|
||||
type="button"
|
||||
aria-label={t('mailInbox.showMail')}
|
||||
className={ROUND}
|
||||
onClick={() => inbox.showMail(entry)}
|
||||
>
|
||||
<FileText size={15} strokeWidth={2} />
|
||||
</button>
|
||||
{rest.map((action) => (
|
||||
@@ -153,14 +168,25 @@ export default function MMailInboxSheet(): ReactElement {
|
||||
<TileHeader
|
||||
icon={
|
||||
back ? (
|
||||
<button type="button" onClick={back} aria-label={t('common.back')} className="grid h-full w-full place-items-center">
|
||||
<button
|
||||
type="button"
|
||||
onClick={back}
|
||||
aria-label={t('common.back')}
|
||||
className="grid h-full w-full place-items-center"
|
||||
>
|
||||
<ChevronLeft size={19} strokeWidth={2} className="rtl:-scale-x-100" />
|
||||
</button>
|
||||
) : (
|
||||
<Inbox size={19} strokeWidth={1.8} />
|
||||
)
|
||||
}
|
||||
title={page === 'pick' ? t('mailInbox.pickTrip') : page === 'mail' ? (inbox.preview?.subject ?? t('mailInbox.untitled')) : t('mailInbox.title')}
|
||||
title={
|
||||
page === 'pick'
|
||||
? t('mailInbox.pickTrip')
|
||||
: page === 'mail'
|
||||
? (inbox.preview?.subject ?? t('mailInbox.untitled'))
|
||||
: t('mailInbox.title')
|
||||
}
|
||||
sub={page === 'list' ? sub : undefined}
|
||||
onClose={inbox.close}
|
||||
closeLabel={t('common.close')}
|
||||
@@ -176,15 +202,23 @@ export default function MMailInboxSheet(): ReactElement {
|
||||
onClick={() => inbox.pick(trip.id)}
|
||||
className={`flex w-full items-baseline justify-between gap-3 rounded-[14px] px-3 py-[11px] text-start ${INNER_CLS}`}
|
||||
>
|
||||
<span dir="auto" className="min-w-0 truncate text-body font-semibold text-m-ink">{trip.title}</span>
|
||||
{trip.start_date && <span className="flex-none font-geist text-caption text-m-muted">{formatDate(trip.start_date, locale)}</span>}
|
||||
<span dir="auto" className="min-w-0 truncate text-body font-semibold text-m-ink">
|
||||
{trip.title}
|
||||
</span>
|
||||
{trip.start_date && (
|
||||
<span className="flex-none font-geist text-caption text-m-muted">
|
||||
{formatDate(trip.start_date, locale)}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
{page === 'mail' && inbox.preview && (
|
||||
<pre className={`whitespace-pre-wrap rounded-[14px] p-3 font-geist text-caption text-m-muted ${INNER_CLS}`}>{inbox.preview.text}</pre>
|
||||
<pre className={`whitespace-pre-wrap rounded-[14px] p-3 font-geist text-caption text-m-muted ${INNER_CLS}`}>
|
||||
{inbox.preview.text}
|
||||
</pre>
|
||||
)}
|
||||
{page === 'list' && inbox.entries.length === 0 && (
|
||||
<div className="flex flex-col items-center gap-2 py-10 text-center">
|
||||
@@ -195,10 +229,17 @@ export default function MMailInboxSheet(): ReactElement {
|
||||
)}
|
||||
{page === 'list' && inbox.entries.length > 0 && (
|
||||
<ul className="flex flex-col gap-2">
|
||||
{inbox.entries.map((entry) => <Entry key={entry.id} entry={entry} inbox={inbox} />)}
|
||||
{inbox.entries.map((entry) => (
|
||||
<Entry key={entry.id} entry={entry} inbox={inbox} />
|
||||
))}
|
||||
{inbox.hasMore && (
|
||||
<li className="flex justify-center pt-1">
|
||||
<button type="button" onClick={inbox.loadMore} disabled={inbox.loading} className="rounded-full bg-[color:var(--m-ic)] px-4 py-2 text-caption font-semibold text-m-ink">
|
||||
<button
|
||||
type="button"
|
||||
onClick={inbox.loadMore}
|
||||
disabled={inbox.loading}
|
||||
className="rounded-full bg-[color:var(--m-ic)] px-4 py-2 text-caption font-semibold text-m-ink"
|
||||
>
|
||||
{t('mailInbox.loadMore')}
|
||||
</button>
|
||||
</li>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useRef, type ReactElement } from 'react';
|
||||
import { Copy, FileUp, Inbox, Mail, RefreshCw } from 'lucide-react';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import { useMailImportSettings } from '../../../components/MailIngest/useMailImportSettings';
|
||||
import { useRef, type ReactElement } from 'react';
|
||||
import { openMailInbox } from '../../../components/MailIngest/mailInboxOpener';
|
||||
import { useMailImportSettings } from '../../../components/MailIngest/useMailImportSettings';
|
||||
import { useTranslation } from '../../../i18n';
|
||||
import MToggle from '../../components/MToggle';
|
||||
import { MSetButton, MSetCard, MSetEyebrow, MSetHint, MSetRow } from './MSettingsUi';
|
||||
|
||||
@@ -27,10 +27,18 @@ export default function MMailImportSection(): ReactElement | null {
|
||||
<>
|
||||
<MSetEyebrow className="mb-[6px]">{t('mailInbox.settings.yourAddress')}</MSetEyebrow>
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
<code dir="ltr" className="min-w-0 flex-1 truncate rounded-[12px] bg-[color:var(--m-ic)] px-3 py-[9px] font-geist text-caption text-m-ink">
|
||||
<code
|
||||
dir="ltr"
|
||||
className="min-w-0 flex-1 truncate rounded-[12px] bg-[color:var(--m-ic)] px-3 py-[9px] font-geist text-caption text-m-ink"
|
||||
>
|
||||
{address.address}
|
||||
</code>
|
||||
<button type="button" onClick={() => void s.copyAddress()} aria-label={t('mailInbox.settings.copy')} className={round}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void s.copyAddress()}
|
||||
aria-label={t('mailInbox.settings.copy')}
|
||||
className={round}
|
||||
>
|
||||
<Copy size={15} strokeWidth={2} />
|
||||
</button>
|
||||
<button
|
||||
@@ -54,7 +62,14 @@ export default function MMailImportSection(): ReactElement | null {
|
||||
first
|
||||
label={t('mailInbox.settings.enabled')}
|
||||
sub={t('mailInbox.settings.enabledHint')}
|
||||
trailing={<MToggle checked={prefs.enabled} disabled={s.saving !== null} onChange={() => void s.toggle('enabled')} ariaLabel={t('mailInbox.settings.enabled')} />}
|
||||
trailing={
|
||||
<MToggle
|
||||
checked={prefs.enabled}
|
||||
disabled={s.saving !== null}
|
||||
onChange={() => void s.toggle('enabled')}
|
||||
ariaLabel={t('mailInbox.settings.enabled')}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<MSetRow
|
||||
label={t('mailInbox.settings.ai')}
|
||||
@@ -86,7 +101,11 @@ export default function MMailImportSection(): ReactElement | null {
|
||||
<div className="mt-3 flex flex-wrap items-center gap-2">
|
||||
<MSetButton variant="ghost" onClick={openMailInbox}>
|
||||
<Inbox size={14} /> {t('mailInbox.title')}
|
||||
{pending > 0 && <span className="rounded-full bg-[color:var(--m-act)] px-[6px] font-geist text-caption font-bold text-[color:var(--m-actfg)]">{pending}</span>}
|
||||
{pending > 0 && (
|
||||
<span className="rounded-full bg-[color:var(--m-act)] px-[6px] font-geist text-caption font-bold text-[color:var(--m-actfg)]">
|
||||
{pending}
|
||||
</span>
|
||||
)}
|
||||
</MSetButton>
|
||||
<MSetButton variant="ghost" onClick={() => file.current?.click()} disabled={s.uploading}>
|
||||
<FileUp size={14} /> {t('mailInbox.settings.upload')}
|
||||
|
||||
@@ -76,7 +76,7 @@ export const useMailIngestStore = create<MailIngestState>((set, get) => ({
|
||||
set((state) => {
|
||||
const stillOpen = OPEN.has(candidate.resolution);
|
||||
const entries = state.entries.flatMap((entry) =>
|
||||
entry.id !== candidate.id ? [entry] : stillOpen ? [{ ...entry, ...candidate }] : [],
|
||||
entry.id !== candidate.id ? [entry] : stillOpen ? [{ ...entry, ...candidate }] : []
|
||||
);
|
||||
const removed = state.entries.length - entries.length;
|
||||
return { entries, pending: Math.max(0, state.pending - removed) };
|
||||
|
||||
@@ -68,9 +68,7 @@ export class MailIngestCursorRepository extends TrekRepository<MailIngestCursor>
|
||||
.set({ lease_owner: owner, lease_until: until })
|
||||
.where('transport', '=', transport)
|
||||
.where('mailbox', '=', mailbox)
|
||||
.where((eb) =>
|
||||
eb.or([eb('lease_until', 'is', null), eb('lease_until', '<', now), eb('lease_owner', '=', owner)]),
|
||||
)
|
||||
.where((eb) => eb.or([eb('lease_until', 'is', null), eb('lease_until', '<', now), eb('lease_owner', '=', owner)]))
|
||||
.executeTakeFirst();
|
||||
return Number(result.numUpdatedRows) > 0;
|
||||
}
|
||||
@@ -126,7 +124,7 @@ export class MailIngestCursorRepository extends TrekRepository<MailIngestCursor>
|
||||
.execute();
|
||||
}
|
||||
|
||||
async find(transport: MailIngestCursorTransport, mailbox: string): Promise<MailIngestCursorRow | null> {
|
||||
async findCursor(transport: MailIngestCursorTransport, mailbox: string): Promise<MailIngestCursorRow | null> {
|
||||
const row = await this.db()
|
||||
.selectFrom('mail_ingest_cursor')
|
||||
.selectAll()
|
||||
|
||||
@@ -18,8 +18,8 @@ import {
|
||||
RECEIPT_USER_TEXT,
|
||||
toReceiptRead,
|
||||
} from './receipt-read';
|
||||
import { routeExtraction, routeImageExtraction, detectFlightNumbers } from './router/extraction-router';
|
||||
import { normalizeCurrency, normalizeNode } from './reservation-normalize';
|
||||
import { routeExtraction, routeImageExtraction, detectFlightNumbers } from './router/extraction-router';
|
||||
import { extractEnforced } from './router/ollama-format.client';
|
||||
import { isPdf, extractText } from './text-extract';
|
||||
import {
|
||||
@@ -43,7 +43,6 @@ export interface LlmParseResult {
|
||||
outcome: LlmParseOutcome;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Orchestrates the LLM fallback: resolve config → pick client → build input
|
||||
* (a photo as an image when the model reads one, a PDF natively for Anthropic,
|
||||
|
||||
@@ -15,13 +15,7 @@ import {
|
||||
mailReadText,
|
||||
readMailAnswer,
|
||||
} from './mail-read';
|
||||
import type {
|
||||
MailReadAttachment,
|
||||
MailReadBooking,
|
||||
MailReading,
|
||||
MailReadInput,
|
||||
WalkedMail,
|
||||
} from './mail-read.types';
|
||||
import type { MailReadAttachment, MailReadBooking, MailReading, MailReadInput, WalkedMail } from './mail-read.types';
|
||||
import { walkMail } from './mime-walker';
|
||||
import { normalizeCurrency, normalizeNode } from './reservation-normalize';
|
||||
import { routeExtraction, routeImageExtraction } from './router/extraction-router';
|
||||
|
||||
@@ -331,10 +331,7 @@ interface RoutedExtraction {
|
||||
* Run the router on extracted document text and return schema.org KiReservation nodes.
|
||||
* Returns `[]` (never throws for content reasons) so the caller degrades gracefully.
|
||||
*/
|
||||
export async function routeExtraction(
|
||||
text: string,
|
||||
ctx: RouterContext,
|
||||
): Promise<RoutedExtraction> {
|
||||
export async function routeExtraction(text: string, ctx: RouterContext): Promise<RoutedExtraction> {
|
||||
const warnings: string[] = [];
|
||||
|
||||
// Schicht 1 — exactly one model call.
|
||||
@@ -371,10 +368,7 @@ export async function routeExtraction(
|
||||
* spot a flight number or a vendor in, so the model picks the type, and the
|
||||
* booking-wide fields come from its answer alone.
|
||||
*/
|
||||
export async function routeImageExtraction(
|
||||
images: Buffer[],
|
||||
ctx: RouterContext,
|
||||
): Promise<RoutedExtraction> {
|
||||
export async function routeImageExtraction(images: Buffer[], ctx: RouterContext): Promise<RoutedExtraction> {
|
||||
let flat: FlatLike;
|
||||
try {
|
||||
flat = unwrapPrice(await extractSingle('', ctx, images));
|
||||
|
||||
@@ -20,9 +20,9 @@ import { UnitOfWork } from '../database/unit-of-work';
|
||||
import { MailReadService } from '../llm-parse/mail-read.service';
|
||||
import type { WalkedMail } from '../llm-parse/mail-read.types';
|
||||
import { MailIngestApplyService, type WrittenBooking } from './mail-ingest-apply.service';
|
||||
import { fitsTrip, implausible, type TripOption } from './mail-ingest-checks';
|
||||
import { MailIngestNotifyService } from './mail-ingest-notify.service';
|
||||
import { MailIngestSettingsService } from './mail-ingest-settings.service';
|
||||
import { fitsTrip, implausible, type TripOption } from './mail-ingest-checks';
|
||||
import { MailIngestTripsService } from './mail-ingest-trips.service';
|
||||
import { ADDED_RESOLUTIONS } from './mail-ingest-views';
|
||||
import { IMPORT_SOURCES, UNDO_WINDOW_DAYS } from './mail-ingest.constants';
|
||||
|
||||
@@ -260,7 +260,19 @@ export class MailIngestApplyService {
|
||||
): CreateReservationData {
|
||||
const { _venue, _accommodation, source: _source, type_guessed: _guessed, needs_review: _review, ...fields } = item;
|
||||
const endpoints = (fields.endpoints ?? []).flatMap((endpoint) =>
|
||||
endpoint.lat != null && endpoint.lng != null ? [{ ...endpoint, lat: endpoint.lat, lng: endpoint.lng }] : [],
|
||||
endpoint.lat != null && endpoint.lng != null
|
||||
? [
|
||||
{
|
||||
...endpoint,
|
||||
lat: endpoint.lat,
|
||||
lng: endpoint.lng,
|
||||
code: endpoint.code ?? null,
|
||||
timezone: endpoint.timezone ?? null,
|
||||
local_time: endpoint.local_time ?? null,
|
||||
local_date: endpoint.local_date ?? null,
|
||||
},
|
||||
]
|
||||
: [],
|
||||
);
|
||||
if (endpoints.length < (fields.endpoints ?? []).length) marked.add('endpoints');
|
||||
return {
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
type MailIngestField,
|
||||
type MailIngestReason,
|
||||
type MailIngestSource,
|
||||
type MailIngestSuggestedTrip,
|
||||
} from '@trek/shared';
|
||||
|
||||
import { createHash } from 'node:crypto';
|
||||
@@ -40,7 +41,7 @@ export interface MailDraft {
|
||||
/** The trip the AI picked, already mapped from its reference to an id of the list; null when it picked none. */
|
||||
aiTripId: number | null;
|
||||
uncertainFields: MailIngestField[];
|
||||
suggestedNewTrip: { destination: string; start_date: string | null; end_date: string | null } | null;
|
||||
suggestedNewTrip: MailIngestSuggestedTrip | null;
|
||||
/** Read from page images alone: nothing can be checked against text. */
|
||||
imageOnly: boolean;
|
||||
/** The AI read a critical field differently from the machine-readable data (G4). */
|
||||
@@ -89,7 +90,8 @@ const CURRENCY_RE = /^[A-Z]{3}$/;
|
||||
* Words that mark a cancellation in the subject. Only the subject: every
|
||||
* hotel confirmation speaks of its free cancellation in the body.
|
||||
*/
|
||||
const CANCEL_RE = /\b(cancel+ed|cancel+ation|storniert|stornierung|annul[ée]e?|annulation|cancelad[ao]|annullat[ao]|geannuleerd|anulowan[ay]|отмен)/i;
|
||||
const CANCEL_RE =
|
||||
/\b(cancel+ed|cancel+ation|storniert|stornierung|annul[ée]e?|annulation|cancelad[ao]|annullat[ao]|geannuleerd|anulowan[ay]|отмен)/i;
|
||||
|
||||
/** The date part of an ISO date or date-time, null for anything else. */
|
||||
export function dateOf(value: string | null | undefined): string | null {
|
||||
|
||||
@@ -55,7 +55,9 @@ export class MailIngestImapJob implements OnApplicationBootstrap {
|
||||
|
||||
onApplicationBootstrap(): void {
|
||||
if (!this.registrar.isEnabled()) return;
|
||||
this.registrar.register('mail-ingest-imap', '*/2 * * * *', () => this.tick());
|
||||
this.registrar.register('mail-ingest-imap', '*/2 * * * *', async () => {
|
||||
await this.tick();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +94,7 @@ export class MailIngestImapJob implements OnApplicationBootstrap {
|
||||
const session = await this.imap.connect(config);
|
||||
try {
|
||||
const { uidValidity } = await session.open(config.mailbox);
|
||||
const position = await this.cursor.find('imap', config.mailbox);
|
||||
const position = await this.cursor.findCursor('imap', config.mailbox);
|
||||
// A changed uid validity means the server renumbered the box: start over, the dedupe keeps each mail once.
|
||||
const after = position?.uid_validity === uidValidity ? (position.last_uid ?? 0) : 0;
|
||||
const due = (await session.listAfter(after)).slice(0, MAILS_PER_RUN);
|
||||
|
||||
@@ -8,8 +8,8 @@ import { MailReadService } from '../llm-parse/mail-read.service';
|
||||
import type { WalkedMail } from '../llm-parse/mail-read.types';
|
||||
import { MailIngestAddressService } from './mail-ingest-address.service';
|
||||
import { MailIngestSettingsService } from './mail-ingest-settings.service';
|
||||
import { sealMail } from './mail-seal';
|
||||
import { MAIL_INGEST_LIMITS } from './mail-ingest.constants';
|
||||
import { sealMail } from './mail-seal';
|
||||
import { InjectRepository } from '@mikro-orm/nestjs';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import type { MailIngestTransport } from '@trek/shared';
|
||||
@@ -18,12 +18,7 @@ import { createHash } from 'node:crypto';
|
||||
|
||||
/** Why a mail was not taken in. A transport answers each the way its protocol does (a 550, a 404, a 413). */
|
||||
export type MailIntakeRefusal =
|
||||
| 'unavailable'
|
||||
| 'too_large'
|
||||
| 'not_a_mail'
|
||||
| 'unknown_address'
|
||||
| 'address_daily_limit'
|
||||
| 'inbox_full';
|
||||
'unavailable' | 'too_large' | 'not_a_mail' | 'unknown_address' | 'address_daily_limit' | 'inbox_full';
|
||||
|
||||
/**
|
||||
* Refusals that pass: the import is switched off for now, the address took
|
||||
@@ -37,8 +32,7 @@ export function isPassingRefusal(reason: MailIntakeRefusal): boolean {
|
||||
}
|
||||
|
||||
type MailIntakeResult =
|
||||
| { status: 'accepted' | 'duplicate'; messageId: number }
|
||||
| { status: 'refused'; reason: MailIntakeRefusal };
|
||||
{ status: 'accepted' | 'duplicate'; messageId: number } | { status: 'refused'; reason: MailIntakeRefusal };
|
||||
|
||||
/** A received mail's outcome over every address it reached. */
|
||||
type MailReceiveResult = { status: 'accepted' | 'duplicate' } | { status: 'refused'; reason: MailIntakeRefusal };
|
||||
|
||||
@@ -35,7 +35,9 @@ export class MailIngestPauseJob implements OnApplicationBootstrap {
|
||||
|
||||
onApplicationBootstrap(): void {
|
||||
if (!this.registrar.isEnabled()) return;
|
||||
this.registrar.register('mail-ingest-pause-notice', '25 * * * *', () => this.tick());
|
||||
this.registrar.register('mail-ingest-pause-notice', '25 * * * *', async () => {
|
||||
await this.tick();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,13 +48,13 @@ export class MailIngestPauseJob implements OnApplicationBootstrap {
|
||||
*/
|
||||
async tick(now: Date = new Date()): Promise<number> {
|
||||
if (await this.settings.isAvailable()) {
|
||||
if ((await this.cursor.find('notice', PAUSED))?.last_ok_at) await this.cursor.forgetOk('notice', PAUSED);
|
||||
if ((await this.cursor.findCursor('notice', PAUSED))?.last_ok_at) await this.cursor.forgetOk('notice', PAUSED);
|
||||
return 0;
|
||||
}
|
||||
const until = dbNow(new Date(now.getTime() + LEASE_MS));
|
||||
if (!(await this.cursor.acquireLease('notice', PAUSED, LEASE_OWNER, until, dbNow(now)))) return 0;
|
||||
try {
|
||||
if ((await this.cursor.find('notice', PAUSED))?.last_ok_at) return 0;
|
||||
if ((await this.cursor.findCursor('notice', PAUSED))?.last_ok_at) return 0;
|
||||
const people = await this.peopleToTell();
|
||||
await this.cursor.recordOk('notice', PAUSED, dbNow(now));
|
||||
await Promise.all(people.map((userId) => this.notify.importPaused(userId)));
|
||||
|
||||
@@ -37,7 +37,9 @@ export class MailIngestProcessJob implements OnApplicationBootstrap {
|
||||
|
||||
onApplicationBootstrap(): void {
|
||||
if (!this.registrar.isEnabled()) return;
|
||||
this.registrar.register('mail-ingest-process', '*/2 * * * *', () => this.tick());
|
||||
this.registrar.register('mail-ingest-process', '*/2 * * * *', async () => {
|
||||
await this.tick();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,7 @@ import { UnitOfWork } from '../database/unit-of-work';
|
||||
import { MailReadService } from '../llm-parse/mail-read.service';
|
||||
import type { WalkedMail } from '../llm-parse/mail-read.types';
|
||||
import { classifyMail, senderVerified } from './mail-classify';
|
||||
import { MailIngestAddressService } from './mail-ingest-address.service';
|
||||
import { MailIngestApplyService, type PreparedBooking, type WrittenBooking } from './mail-ingest-apply.service';
|
||||
import {
|
||||
bookingStart,
|
||||
@@ -38,7 +39,6 @@ import {
|
||||
type MailDraft,
|
||||
type TripOption,
|
||||
} from './mail-ingest-checks';
|
||||
import { MailIngestAddressService } from './mail-ingest-address.service';
|
||||
import { MailIngestNotifyService } from './mail-ingest-notify.service';
|
||||
import { MailIngestReadingService } from './mail-ingest-reading.service';
|
||||
import { MailIngestSettingsService } from './mail-ingest-settings.service';
|
||||
|
||||
@@ -73,7 +73,9 @@ export class MailIngestRelayJob implements OnApplicationBootstrap {
|
||||
|
||||
onApplicationBootstrap(): void {
|
||||
if (!this.registrar.isEnabled()) return;
|
||||
this.registrar.register('mail-ingest-relay', '*/2 * * * *', () => this.tick());
|
||||
this.registrar.register('mail-ingest-relay', '*/2 * * * *', async () => {
|
||||
await this.tick();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +108,7 @@ export class MailIngestRelayJob implements OnApplicationBootstrap {
|
||||
if (answer === null) return 0;
|
||||
const page = relayPageSchema.safeParse(answer);
|
||||
if (!page.success) throw new Error('The relay answered with an inbox this server cannot read');
|
||||
const taken = await page.data.messages.reduce(async (previous, item) => {
|
||||
const taken = await page.data.messages.reduce<Promise<number>>(async (previous, item) => {
|
||||
const count = await previous;
|
||||
return count + ((await this.takeIn(relay, item)) ? 1 : 0);
|
||||
}, Promise.resolve(0));
|
||||
|
||||
@@ -108,8 +108,8 @@ export class MailIngestStatusService {
|
||||
private async readerCursor(transport: MailIngestTransportSetting) {
|
||||
if (transport === 'imap') {
|
||||
const config = await this.settings.imapConfig();
|
||||
return config ? this.cursor.find('imap', config.mailbox) : null;
|
||||
return config ? this.cursor.findCursor('imap', config.mailbox) : null;
|
||||
}
|
||||
return this.cursor.find(transport === 'cloud' ? 'cloud' : 'pipeline', '');
|
||||
return this.cursor.findCursor(transport === 'cloud' ? 'cloud' : 'pipeline', '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,5 +113,8 @@ function verifyWebhook(secret: string, signed: WebhookSignedParts, recipient: st
|
||||
|
||||
/** The hex signature as sent, with or without its `sha256=` prefix. */
|
||||
function signatureOf(signed: WebhookSignedParts): string {
|
||||
return (signed.signature ?? '').trim().replace(/^sha256=/i, '').toLowerCase();
|
||||
return (signed.signature ?? '')
|
||||
.trim()
|
||||
.replace(/^sha256=/i, '')
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
@@ -83,12 +83,7 @@ import { Module } from '@nestjs/common';
|
||||
MailIngestCandidates,
|
||||
]),
|
||||
],
|
||||
controllers: [
|
||||
MailIngestController,
|
||||
MailIngestTripController,
|
||||
MailIngestAdminController,
|
||||
MailIngestInboundController,
|
||||
],
|
||||
controllers: [MailIngestController, MailIngestTripController, MailIngestAdminController, MailIngestInboundController],
|
||||
providers: [
|
||||
MailIngestSettingsService,
|
||||
MailIngestTripsService,
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
*/
|
||||
import { db } from '../../src/db/database';
|
||||
import { Reservations } from '../../src/db/entities/Reservations.entity';
|
||||
import { importExternalId } from '../../src/nest/booking-import/booking-origin';
|
||||
import { BookingImportService } from '../../src/nest/booking-import/booking-import.service';
|
||||
import { importExternalId } from '../../src/nest/booking-import/booking-origin';
|
||||
import { encrypt_api_key } from '../../src/nest/common/crypto/apiKeyCrypto';
|
||||
import { TrekExceptionFilter } from '../../src/nest/common/trek-exception.filter';
|
||||
import { ZodValidationPipe } from '../../src/nest/common/zod-validation.pipe';
|
||||
|
||||
@@ -42,25 +42,25 @@ describe('MailIngestCursorRepository', () => {
|
||||
expect(await cursor.acquireLease('pipeline', '', 'b', T2, dbNow(new Date('2026-11-01T10:11:00Z')))).toBe(true);
|
||||
|
||||
await cursor.releaseLease('pipeline', '', 'a');
|
||||
expect(await cursor.find('pipeline', '')).toMatchObject({ lease_owner: 'b' });
|
||||
expect(await cursor.findCursor('pipeline', '')).toMatchObject({ lease_owner: 'b' });
|
||||
await cursor.releaseLease('pipeline', '', 'b');
|
||||
expect(await cursor.find('pipeline', '')).toMatchObject({ lease_owner: null, lease_until: null });
|
||||
expect(await cursor.findCursor('pipeline', '')).toMatchObject({ lease_owner: null, lease_until: null });
|
||||
});
|
||||
|
||||
it('keeps the position of a good run and the error of a bad one', async () => {
|
||||
await cursor.acquireLease('imap', 'INBOX', 'a', T1, T0);
|
||||
await cursor.recordOk('imap', 'INBOX', T0, { uidValidity: 7, lastUid: 42 });
|
||||
await cursor.recordError('imap', 'INBOX', 'x'.repeat(600));
|
||||
let row = await cursor.find('imap', 'INBOX');
|
||||
let row = await cursor.findCursor('imap', 'INBOX');
|
||||
expect(row).toMatchObject({ uid_validity: 7, last_uid: 42, last_ok_at: T0 });
|
||||
expect(row?.last_error).toHaveLength(500);
|
||||
|
||||
await cursor.recordOk('imap', 'INBOX', T1);
|
||||
row = await cursor.find('imap', 'INBOX');
|
||||
row = await cursor.findCursor('imap', 'INBOX');
|
||||
expect(row).toMatchObject({ uid_validity: 7, last_uid: 42, last_ok_at: T1, last_error: null });
|
||||
|
||||
await cursor.forgetOk('imap', 'INBOX');
|
||||
expect(await cursor.find('imap', 'INBOX')).toMatchObject({ uid_validity: 7, last_ok_at: null });
|
||||
expect(await cursor.find('cloud', '')).toBeNull();
|
||||
expect(await cursor.findCursor('imap', 'INBOX')).toMatchObject({ uid_validity: 7, last_ok_at: null });
|
||||
expect(await cursor.findCursor('cloud', '')).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1105,7 +1105,9 @@ describe('ReservationsRepository — the origin of an imported booking', () => {
|
||||
const trip = createTrip(testDb, user.id);
|
||||
const id = await reservationsRepo.insertReservation(baseRow(trip.id));
|
||||
// test-sql-allow: reads back the raw columns the insert left to their defaults.
|
||||
const row = testDb.prepare('SELECT external_source, external_id, sync_enabled FROM reservations WHERE id = ?').get(id);
|
||||
const row = testDb
|
||||
.prepare('SELECT external_source, external_id, sync_enabled FROM reservations WHERE id = ?')
|
||||
.get(id);
|
||||
expect(row).toEqual({ external_source: null, external_id: null, sync_enabled: 1 });
|
||||
});
|
||||
|
||||
@@ -1120,11 +1122,21 @@ describe('ReservationsRepository — the origin of an imported booking', () => {
|
||||
sync_enabled: 0,
|
||||
});
|
||||
// test-sql-allow: reads back the raw origin columns the insert named.
|
||||
const row = testDb.prepare('SELECT external_source, external_id, sync_enabled FROM reservations WHERE id = ?').get(id);
|
||||
expect(row).toEqual({ external_source: 'import', external_id: 'ABC123|flight|2026-09-01|FRA-NRT', sync_enabled: 0 });
|
||||
const row = testDb
|
||||
.prepare('SELECT external_source, external_id, sync_enabled FROM reservations WHERE id = ?')
|
||||
.get(id);
|
||||
expect(row).toEqual({
|
||||
external_source: 'import',
|
||||
external_id: 'ABC123|flight|2026-09-01|FRA-NRT',
|
||||
sync_enabled: 0,
|
||||
});
|
||||
|
||||
expect(await reservationsRepo.findIdByExternal(trip.id, 'import', 'ABC123|flight|2026-09-01|FRA-NRT')).toBe(id);
|
||||
expect(await reservationsRepo.findIdByExternal(other.id, 'import', 'ABC123|flight|2026-09-01|FRA-NRT')).toBeUndefined();
|
||||
expect(await reservationsRepo.findIdByExternal(trip.id, 'mail', 'ABC123|flight|2026-09-01|FRA-NRT')).toBeUndefined();
|
||||
expect(
|
||||
await reservationsRepo.findIdByExternal(other.id, 'import', 'ABC123|flight|2026-09-01|FRA-NRT'),
|
||||
).toBeUndefined();
|
||||
expect(
|
||||
await reservationsRepo.findIdByExternal(trip.id, 'mail', 'ABC123|flight|2026-09-01|FRA-NRT'),
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -48,12 +48,10 @@ async function make(opts: Opts = {}) {
|
||||
items: Array.from({ length: MAX_WRITES_PER_STEP + 2 }, (_, index) => ({ ...ITEM, title: `Leg ${index}` })),
|
||||
warnings: [],
|
||||
})),
|
||||
confirm: vi.fn(
|
||||
async (): Promise<{ created: unknown[]; failed: { index: number; reason: string }[] }> => ({
|
||||
created: [{ id: 81, title: 'ICE 123', type: 'train', day_id: 31 }],
|
||||
failed: [],
|
||||
}),
|
||||
),
|
||||
confirm: vi.fn(async (): Promise<{ created: unknown[]; failed: { index: number; reason: string }[] }> => ({
|
||||
created: [{ id: 81, title: 'ICE 123', type: 'train', day_id: 31 }],
|
||||
failed: [],
|
||||
})),
|
||||
};
|
||||
const trips = { findAccessible: vi.fn(async () => (opts.trip === false ? undefined : { id: 5, user_id: 7 })) };
|
||||
const guards = { hasTripPermission: vi.fn(async () => opts.right !== false) };
|
||||
|
||||
@@ -18,9 +18,7 @@ vi.mock('../../../../src/db/database', () => ({
|
||||
const permissionsStub = { checkPermission: vi.fn(async () => true) };
|
||||
// confirm() checks the trip and the person's right itself: the trip is reachable, the role a plain user's.
|
||||
const usersStub = { getRole: vi.fn(async () => 'user') };
|
||||
const tripAccess = vi.fn(
|
||||
async (): Promise<{ id: number; user_id: number } | undefined> => ({ id: 5, user_id: 1 }),
|
||||
);
|
||||
const tripAccess = vi.fn(async (): Promise<{ id: number; user_id: number } | undefined> => ({ id: 5, user_id: 1 }));
|
||||
// No earlier import holds any key unless a test says so.
|
||||
const findIdByExternal = vi.fn(async (): Promise<number | undefined> => undefined);
|
||||
const reservationsRepoStub = { findIdByExternal };
|
||||
|
||||
@@ -87,11 +87,7 @@ describe('MailReadService.read', () => {
|
||||
|
||||
it('reads a mail in one request with the trip list and the bookings root', async () => {
|
||||
extract.mockResolvedValue([{ kind: 'new_booking', reservations: [flight], trip_ref: 't1', trip_confidence: 0.8 }]);
|
||||
const reading = await service.read(
|
||||
input({ attachments: [pdf], hints: [{ type: 'flight' }] }),
|
||||
1,
|
||||
'2026-11-13',
|
||||
);
|
||||
const reading = await service.read(input({ attachments: [pdf], hints: [{ type: 'flight' }] }), 1, '2026-11-13');
|
||||
|
||||
expect(extract).toHaveBeenCalledTimes(1);
|
||||
const sent = extract.mock.calls[0][0];
|
||||
@@ -178,4 +174,3 @@ describe('MailReadService helpers', () => {
|
||||
expect(isAvailable).toHaveBeenCalledWith(4);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -303,11 +303,7 @@ describe('walkMail: attachments', () => {
|
||||
|
||||
it('MIME-WALK-025: a file name loses its path and control characters, an empty one is made up', () => {
|
||||
const walked = walkMail(
|
||||
mixed(
|
||||
'Booking',
|
||||
part('application/pdf', '../../etc/ticket\u0007.pdf', PDF),
|
||||
part('application/pdf', '..', PDF),
|
||||
),
|
||||
mixed('Booking', part('application/pdf', '../../etc/ticket\u0007.pdf', PDF), part('application/pdf', '..', PDF)),
|
||||
)!;
|
||||
expect(walked.attachments.map((a) => a.fileName)).toEqual(['ticket.pdf', 'attachment-2.pdf']);
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ const settings = {
|
||||
prefsOf: vi.fn(async (userId: number) => ({ enabled: userId !== 3, ai_enabled: true, auto_add: true })),
|
||||
};
|
||||
const cursor = {
|
||||
find: vi.fn(),
|
||||
findCursor: vi.fn(),
|
||||
acquireLease: vi.fn(async () => true),
|
||||
releaseLease: vi.fn(async () => undefined),
|
||||
recordOk: vi.fn(async () => undefined),
|
||||
@@ -44,7 +44,7 @@ let job: MailIngestPauseJob;
|
||||
beforeEach(async () => {
|
||||
vi.clearAllMocks();
|
||||
settings.isAvailable.mockResolvedValue(false);
|
||||
cursor.find.mockResolvedValue(null);
|
||||
cursor.findCursor.mockResolvedValue(null);
|
||||
cursor.acquireLease.mockResolvedValue(true);
|
||||
const moduleRef = await Test.createTestingModule({
|
||||
providers: [
|
||||
@@ -67,7 +67,7 @@ describe('the pause notice', () => {
|
||||
expect(cursor.recordOk.mock.invocationCallOrder[0]).toBeLessThan(notify.importPaused.mock.invocationCallOrder[0]);
|
||||
expect(cursor.releaseLease).toHaveBeenCalled();
|
||||
|
||||
cursor.find.mockResolvedValue({ last_ok_at: '2030-01-15 10:00:00' });
|
||||
cursor.findCursor.mockResolvedValue({ last_ok_at: '2030-01-15 10:00:00' });
|
||||
expect(await job.tick(NOW)).toBe(0);
|
||||
expect(notify.importPaused).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
@@ -82,7 +82,7 @@ describe('the pause notice', () => {
|
||||
settings.isAvailable.mockResolvedValue(true);
|
||||
expect(await job.tick(NOW)).toBe(0);
|
||||
expect(cursor.forgetOk).not.toHaveBeenCalled();
|
||||
cursor.find.mockResolvedValue({ last_ok_at: '2030-01-15 10:00:00' });
|
||||
cursor.findCursor.mockResolvedValue({ last_ok_at: '2030-01-15 10:00:00' });
|
||||
expect(await job.tick(NOW)).toBe(0);
|
||||
expect(cursor.forgetOk).toHaveBeenCalledWith('notice', 'paused');
|
||||
expect(notify.importPaused).not.toHaveBeenCalled();
|
||||
|
||||
@@ -77,7 +77,7 @@ const cursor = {
|
||||
releaseLease: vi.fn(async () => undefined),
|
||||
recordOk: vi.fn(async () => undefined),
|
||||
recordError: vi.fn(async () => undefined),
|
||||
find: vi.fn(),
|
||||
findCursor: vi.fn(),
|
||||
};
|
||||
const messages = { tallySince: vi.fn(), countAllAiReadSince: vi.fn() };
|
||||
const candidates = { tallyResolutionsSince: vi.fn(), pendingPerUser: vi.fn() };
|
||||
@@ -120,7 +120,7 @@ beforeEach(async () => {
|
||||
settings.webhookSecret.mockResolvedValue('a'.repeat(32));
|
||||
settings.imapConfig.mockResolvedValue(IMAP);
|
||||
cursor.acquireLease.mockResolvedValue(true);
|
||||
cursor.find.mockResolvedValue(null);
|
||||
cursor.findCursor.mockResolvedValue(null);
|
||||
relays = new MailIngestRelayHost();
|
||||
app = await build();
|
||||
});
|
||||
@@ -209,7 +209,7 @@ describe('the IMAP run', () => {
|
||||
});
|
||||
|
||||
it('takes the new mails after the cursor, moves them on, and notes where it got to', async () => {
|
||||
cursor.find.mockResolvedValue({ uid_validity: 9, last_uid: 40 });
|
||||
cursor.findCursor.mockResolvedValue({ uid_validity: 9, last_uid: 40 });
|
||||
boxes([ref(41), ref(42)]);
|
||||
expect(await job().tick(NOW)).toBe(2);
|
||||
expect(session.listAfter).toHaveBeenNthCalledWith(1, 40);
|
||||
@@ -222,7 +222,7 @@ describe('the IMAP run', () => {
|
||||
});
|
||||
|
||||
it('starts over when the server renumbered the box, and leaves a mail over the limit unread', async () => {
|
||||
cursor.find.mockResolvedValue({ uid_validity: 3, last_uid: 400 });
|
||||
cursor.findCursor.mockResolvedValue({ uid_validity: 3, last_uid: 400 });
|
||||
boxes([ref(1, 5000), ref(2)]);
|
||||
expect(await job().tick(NOW)).toBe(1);
|
||||
expect(session.listAfter).toHaveBeenNthCalledWith(1, 0);
|
||||
@@ -403,7 +403,7 @@ describe('the status card and the connection test', () => {
|
||||
|
||||
it('counts the last day by status and reason, and names no mail and no person', async () => {
|
||||
settings.transport.mockResolvedValue('cloud');
|
||||
cursor.find.mockResolvedValue({ last_ok_at: '2030-01-15 09:58:00', last_error: null, lease_until: null });
|
||||
cursor.findCursor.mockResolvedValue({ last_ok_at: '2030-01-15 09:58:00', last_error: null, lease_until: null });
|
||||
messages.tallySince.mockResolvedValue([
|
||||
{ status: 'processed', reason: null, n: 4 },
|
||||
{ status: 'discarded', reason: 'newsletter', n: 2 },
|
||||
@@ -430,7 +430,7 @@ describe('the status card and the connection test', () => {
|
||||
ai_calls_today: 3,
|
||||
backlog: [4, 1],
|
||||
});
|
||||
expect(cursor.find).toHaveBeenCalledWith('cloud', '');
|
||||
expect(cursor.findCursor).toHaveBeenCalledWith('cloud', '');
|
||||
expect(messages.countAllAiReadSince).toHaveBeenCalledWith('2030-01-15 00:00:00');
|
||||
});
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import { BudgetItems } from '../../../../src/db/entities/BudgetItems.entity';
|
||||
import { MailIngestCandidates } from '../../../../src/db/entities/MailIngestCandidates.entity';
|
||||
import { MailIngestMessages } from '../../../../src/db/entities/MailIngestMessages.entity';
|
||||
import { Reservations } from '../../../../src/db/entities/Reservations.entity';
|
||||
import { importExternalId } from '../../../../src/nest/booking-import/booking-origin';
|
||||
import { BookingImportService } from '../../../../src/nest/booking-import/booking-import.service';
|
||||
import { importExternalId } from '../../../../src/nest/booking-import/booking-origin';
|
||||
import { DemoService } from '../../../../src/nest/common/demo.service';
|
||||
import { DomainError } from '../../../../src/nest/common/domain-error';
|
||||
import { FilesService } from '../../../../src/nest/files/files.service';
|
||||
|
||||
@@ -65,7 +65,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'حجوزات مُعاد توجيهها للمراجعة',
|
||||
'notif.mail_booking_pending.text': 'حجوزات مُعاد توجيهها بانتظارك: {count}',
|
||||
'notif.mail_ingest_paused.title': 'تم إيقاف استيراد البريد مؤقتًا',
|
||||
'notif.mail_ingest_paused.text': 'لا تُقبل رسائل الحجز المُعاد توجيهها في الوقت الحالي. تبقى عناوينك وستعمل مجددًا عند عودة الاستيراد.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'لا تُقبل رسائل الحجز المُعاد توجيهها في الوقت الحالي. تبقى عناوينك وستعمل مجددًا عند عودة الاستيراد.',
|
||||
'notif.action.undo': 'تراجع',
|
||||
'notif.action.keep': 'إبقاء',
|
||||
'notif.action.review': 'مراجعة',
|
||||
|
||||
@@ -62,7 +62,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Yoxlanılacaq yönləndirilmiş rezervasiyalar',
|
||||
'notif.mail_booking_pending.text': 'Sizi gözləyən yönləndirilmiş rezervasiyalar: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Poçt idxalı dayandırılıb',
|
||||
'notif.mail_ingest_paused.text': 'Yönləndirilmiş rezervasiya məktubları hələlik qəbul edilmir. Ünvanlarınız qalır və idxal geri qayıdanda yenidən işləyəcək.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Yönləndirilmiş rezervasiya məktubları hələlik qəbul edilmir. Ünvanlarınız qalır və idxal geri qayıdanda yenidən işləyəcək.',
|
||||
'notif.action.undo': 'Geri al',
|
||||
'notif.action.keep': 'Saxla',
|
||||
'notif.action.review': 'Yoxla',
|
||||
|
||||
@@ -61,7 +61,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Reservas encaminhadas para revisar',
|
||||
'notif.mail_booking_pending.text': 'Reservas encaminhadas aguardando você: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Importação de e-mails pausada',
|
||||
'notif.mail_ingest_paused.text': 'Por enquanto, os e-mails de reserva encaminhados não são aceitos. Seus endereços continuam e voltam a funcionar quando a importação voltar.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Por enquanto, os e-mails de reserva encaminhados não são aceitos. Seus endereços continuam e voltam a funcionar quando a importação voltar.',
|
||||
'notif.action.undo': 'Desfazer',
|
||||
'notif.action.keep': 'Manter',
|
||||
'notif.action.review': 'Revisar',
|
||||
|
||||
@@ -66,7 +66,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Reserves reenviades per revisar',
|
||||
'notif.mail_booking_pending.text': 'Reserves reenviades pendents: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Importació de correus en pausa',
|
||||
'notif.mail_ingest_paused.text': 'De moment no s’accepten els correus de reserva reenviats. Les teves adreces es mantenen i tornaran a funcionar quan torni la importació.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'De moment no s’accepten els correus de reserva reenviats. Les teves adreces es mantenen i tornaran a funcionar quan torni la importació.',
|
||||
'notif.action.undo': 'Desfés',
|
||||
'notif.action.keep': 'Conserva',
|
||||
'notif.action.review': 'Revisa',
|
||||
|
||||
@@ -62,7 +62,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Přeposlané rezervace ke kontrole',
|
||||
'notif.mail_booking_pending.text': 'Přeposlané rezervace čekající na vás: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Import e-mailů pozastaven',
|
||||
'notif.mail_ingest_paused.text': 'Přeposlané e-maily s rezervacemi se zatím nepřijímají. Vaše adresy zůstávají a znovu budou fungovat, až se import vrátí.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Přeposlané e-maily s rezervacemi se zatím nepřijímají. Vaše adresy zůstávají a znovu budou fungovat, až se import vrátí.',
|
||||
'notif.action.undo': 'Vrátit zpět',
|
||||
'notif.action.keep': 'Ponechat',
|
||||
'notif.action.review': 'Zkontrolovat',
|
||||
|
||||
@@ -61,7 +61,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Weitergeleitete Buchungen prüfen',
|
||||
'notif.mail_booking_pending.text': 'Weitergeleitete Buchungen warten auf dich: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Mail-Import pausiert',
|
||||
'notif.mail_ingest_paused.text': 'Weitergeleitete Buchungsmails werden vorerst nicht angenommen. Deine Adressen bleiben und funktionieren wieder, sobald der Import zurück ist.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Weitergeleitete Buchungsmails werden vorerst nicht angenommen. Deine Adressen bleiben und funktionieren wieder, sobald der Import zurück ist.',
|
||||
'notif.action.undo': 'Rückgängig',
|
||||
'notif.action.keep': 'Behalten',
|
||||
'notif.action.review': 'Prüfen',
|
||||
|
||||
@@ -61,7 +61,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Forwarded bookings to review',
|
||||
'notif.mail_booking_pending.text': 'Forwarded bookings waiting for you: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Mail import paused',
|
||||
'notif.mail_ingest_paused.text': 'Forwarded booking mails are not taken in for now. Your addresses stay and work again once the import is back.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Forwarded booking mails are not taken in for now. Your addresses stay and work again once the import is back.',
|
||||
'notif.action.undo': 'Undo',
|
||||
'notif.action.keep': 'Keep',
|
||||
'notif.action.review': 'Review',
|
||||
|
||||
@@ -61,7 +61,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Reservas reenviadas por revisar',
|
||||
'notif.mail_booking_pending.text': 'Reservas reenviadas pendientes: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Importación de correos en pausa',
|
||||
'notif.mail_ingest_paused.text': 'Por ahora no se aceptan los correos de reserva reenviados. Tus direcciones se mantienen y volverán a funcionar cuando vuelva la importación.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Por ahora no se aceptan los correos de reserva reenviados. Tus direcciones se mantienen y volverán a funcionar cuando vuelva la importación.',
|
||||
'notif.action.undo': 'Deshacer',
|
||||
'notif.action.keep': 'Mantener',
|
||||
'notif.action.review': 'Revisar',
|
||||
|
||||
@@ -61,7 +61,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Ülevaatamist ootavad edastatud broneeringud',
|
||||
'notif.mail_booking_pending.text': 'Sind ootavad edastatud broneeringud: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Kirjade import on peatatud',
|
||||
'notif.mail_ingest_paused.text': 'Edastatud broneeringukirju praegu vastu ei võeta. Sinu aadressid jäävad alles ja töötavad uuesti, kui import tagasi on.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Edastatud broneeringukirju praegu vastu ei võeta. Sinu aadressid jäävad alles ja töötavad uuesti, kui import tagasi on.',
|
||||
'notif.action.undo': 'Võta tagasi',
|
||||
'notif.action.keep': 'Jäta alles',
|
||||
'notif.action.review': 'Vaata üle',
|
||||
|
||||
@@ -61,7 +61,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Réservations transférées à vérifier',
|
||||
'notif.mail_booking_pending.text': 'Réservations transférées en attente : {count}',
|
||||
'notif.mail_ingest_paused.title': 'Import des e-mails en pause',
|
||||
'notif.mail_ingest_paused.text': 'Les e-mails de réservation transférés ne sont pas acceptés pour le moment. Vos adresses restent et fonctionneront de nouveau au retour de l’import.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Les e-mails de réservation transférés ne sont pas acceptés pour le moment. Vos adresses restent et fonctionneront de nouveau au retour de l’import.',
|
||||
'notif.action.undo': 'Annuler',
|
||||
'notif.action.keep': 'Garder',
|
||||
'notif.action.review': 'Vérifier',
|
||||
|
||||
@@ -61,7 +61,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Προωθημένες κρατήσεις για έλεγχο',
|
||||
'notif.mail_booking_pending.text': 'Προωθημένες κρατήσεις σε αναμονή: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Η εισαγωγή email σε παύση',
|
||||
'notif.mail_ingest_paused.text': 'Τα προωθημένα email κρατήσεων δεν γίνονται δεκτά προς το παρόν. Οι διευθύνσεις σου μένουν και θα λειτουργήσουν ξανά όταν επιστρέψει η εισαγωγή.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Τα προωθημένα email κρατήσεων δεν γίνονται δεκτά προς το παρόν. Οι διευθύνσεις σου μένουν και θα λειτουργήσουν ξανά όταν επιστρέψει η εισαγωγή.',
|
||||
'notif.action.undo': 'Αναίρεση',
|
||||
'notif.action.keep': 'Διατήρηση',
|
||||
'notif.action.review': 'Έλεγχος',
|
||||
|
||||
@@ -62,7 +62,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'הזמנות שהועברו לבדיקה',
|
||||
'notif.mail_booking_pending.text': 'הזמנות שהועברו וממתינות לכם: {count}',
|
||||
'notif.mail_ingest_paused.title': 'ייבוא הדואר מושהה',
|
||||
'notif.mail_ingest_paused.text': 'הודעות הזמנה שהועברו אינן מתקבלות כרגע. הכתובות שלכם נשמרות ויעבדו שוב כשהייבוא יחזור.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'הודעות הזמנה שהועברו אינן מתקבלות כרגע. הכתובות שלכם נשמרות ויעבדו שוב כשהייבוא יחזור.',
|
||||
'notif.action.undo': 'ביטול',
|
||||
'notif.action.keep': 'השארה',
|
||||
'notif.action.review': 'בדיקה',
|
||||
|
||||
@@ -61,7 +61,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Ellenőrizendő továbbított foglalások',
|
||||
'notif.mail_booking_pending.text': 'Rád váró továbbított foglalások: {count}',
|
||||
'notif.mail_ingest_paused.title': 'E-mail-importálás szüneteltetve',
|
||||
'notif.mail_ingest_paused.text': 'A továbbított foglalási e-maileket egyelőre nem fogadjuk. A címeid megmaradnak, és újra működnek, amint az importálás visszatér.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'A továbbított foglalási e-maileket egyelőre nem fogadjuk. A címeid megmaradnak, és újra működnek, amint az importálás visszatér.',
|
||||
'notif.action.undo': 'Visszavonás',
|
||||
'notif.action.keep': 'Megtartás',
|
||||
'notif.action.review': 'Ellenőrzés',
|
||||
|
||||
@@ -60,7 +60,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Pemesanan terusan untuk ditinjau',
|
||||
'notif.mail_booking_pending.text': 'Pemesanan terusan yang menunggumu: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Impor email dijeda',
|
||||
'notif.mail_ingest_paused.text': 'Email pemesanan yang diteruskan untuk sementara tidak diterima. Alamatmu tetap ada dan akan berfungsi lagi saat impor kembali.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Email pemesanan yang diteruskan untuk sementara tidak diterima. Alamatmu tetap ada dan akan berfungsi lagi saat impor kembali.',
|
||||
'notif.action.undo': 'Urungkan',
|
||||
'notif.action.keep': 'Simpan',
|
||||
'notif.action.review': 'Tinjau',
|
||||
|
||||
@@ -61,7 +61,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Prenotazioni inoltrate da controllare',
|
||||
'notif.mail_booking_pending.text': 'Prenotazioni inoltrate in attesa: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Importazione email in pausa',
|
||||
'notif.mail_ingest_paused.text': 'Per ora le email di prenotazione inoltrate non vengono accettate. I tuoi indirizzi restano e funzioneranno di nuovo quando l’importazione tornerà.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Per ora le email di prenotazione inoltrate non vengono accettate. I tuoi indirizzi restano e funzioneranno di nuovo quando l’importazione tornerà.',
|
||||
'notif.action.undo': 'Annulla',
|
||||
'notif.action.keep': 'Mantieni',
|
||||
'notif.action.review': 'Controlla',
|
||||
|
||||
@@ -60,7 +60,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': '確認待ちの転送予約',
|
||||
'notif.mail_booking_pending.text': '確認待ちの転送予約: {count} 件',
|
||||
'notif.mail_ingest_paused.title': 'メール取り込みを一時停止中',
|
||||
'notif.mail_ingest_paused.text': '転送された予約メールは現在受け付けていません。アドレスはそのまま残り、取り込みが再開されると再び使えます。',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'転送された予約メールは現在受け付けていません。アドレスはそのまま残り、取り込みが再開されると再び使えます。',
|
||||
'notif.action.undo': '元に戻す',
|
||||
'notif.action.keep': '残す',
|
||||
'notif.action.review': '確認',
|
||||
|
||||
@@ -60,7 +60,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': '검토할 전달된 예약',
|
||||
'notif.mail_booking_pending.text': '검토를 기다리는 전달된 예약: {count}개',
|
||||
'notif.mail_ingest_paused.title': '메일 가져오기 일시 중지됨',
|
||||
'notif.mail_ingest_paused.text': '전달된 예약 메일은 당분간 받지 않습니다. 주소는 그대로 유지되며 가져오기가 다시 시작되면 다시 작동합니다.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'전달된 예약 메일은 당분간 받지 않습니다. 주소는 그대로 유지되며 가져오기가 다시 시작되면 다시 작동합니다.',
|
||||
'notif.action.undo': '실행 취소',
|
||||
'notif.action.keep': '유지',
|
||||
'notif.action.review': '검토',
|
||||
|
||||
@@ -61,7 +61,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Doorgestuurde boekingen om te controleren',
|
||||
'notif.mail_booking_pending.text': 'Doorgestuurde boekingen wachten op je: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Mailimport gepauzeerd',
|
||||
'notif.mail_ingest_paused.text': 'Doorgestuurde boekingsmails worden voorlopig niet aangenomen. Je adressen blijven en werken weer zodra de import terug is.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Doorgestuurde boekingsmails worden voorlopig niet aangenomen. Je adressen blijven en werken weer zodra de import terug is.',
|
||||
'notif.action.undo': 'Ongedaan maken',
|
||||
'notif.action.keep': 'Behouden',
|
||||
'notif.action.review': 'Controleren',
|
||||
|
||||
@@ -63,7 +63,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Przekazane rezerwacje do sprawdzenia',
|
||||
'notif.mail_booking_pending.text': 'Przekazane rezerwacje czekające na Ciebie: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Import e-maili wstrzymany',
|
||||
'notif.mail_ingest_paused.text': 'Przekazane e-maile z rezerwacjami nie są na razie przyjmowane. Twoje adresy zostają i znów zadziałają, gdy import wróci.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Przekazane e-maile z rezerwacjami nie są na razie przyjmowane. Twoje adresy zostają i znów zadziałają, gdy import wróci.',
|
||||
'notif.action.undo': 'Cofnij',
|
||||
'notif.action.keep': 'Zachowaj',
|
||||
'notif.action.review': 'Sprawdź',
|
||||
|
||||
@@ -63,7 +63,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Пересланные бронирования для проверки',
|
||||
'notif.mail_booking_pending.text': 'Пересланных бронирований ждёт вас: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Импорт писем приостановлен',
|
||||
'notif.mail_ingest_paused.text': 'Пересланные письма с бронированиями пока не принимаются. Ваши адреса сохраняются и снова заработают, когда импорт вернётся.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Пересланные письма с бронированиями пока не принимаются. Ваши адреса сохраняются и снова заработают, когда импорт вернётся.',
|
||||
'notif.action.undo': 'Отменить',
|
||||
'notif.action.keep': 'Оставить',
|
||||
'notif.action.review': 'Проверить',
|
||||
|
||||
@@ -62,7 +62,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Preposlané rezervácie na kontrolu',
|
||||
'notif.mail_booking_pending.text': 'Preposlané rezervácie čakajúce na vás: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Import e-mailov pozastavený',
|
||||
'notif.mail_ingest_paused.text': 'Preposlané e-maily s rezerváciami sa zatiaľ neprijímajú. Vaše adresy zostávajú a znova budú fungovať, keď sa import vráti.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Preposlané e-maily s rezerváciami sa zatiaľ neprijímajú. Vaše adresy zostávajú a znova budú fungovať, keď sa import vráti.',
|
||||
'notif.action.undo': 'Vrátiť späť',
|
||||
'notif.action.keep': 'Ponechať',
|
||||
'notif.action.review': 'Skontrolovať',
|
||||
|
||||
@@ -61,7 +61,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Vidarebefordrade bokningar att granska',
|
||||
'notif.mail_booking_pending.text': 'Vidarebefordrade bokningar som väntar på dig: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Mejlimport pausad',
|
||||
'notif.mail_ingest_paused.text': 'Vidarebefordrade bokningsmejl tas inte emot just nu. Dina adresser finns kvar och fungerar igen när importen är tillbaka.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Vidarebefordrade bokningsmejl tas inte emot just nu. Dina adresser finns kvar och fungerar igen när importen är tillbaka.',
|
||||
'notif.action.undo': 'Ångra',
|
||||
'notif.action.keep': 'Behåll',
|
||||
'notif.action.review': 'Granska',
|
||||
|
||||
@@ -60,7 +60,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'การจองที่ส่งต่อซึ่งรอตรวจสอบ',
|
||||
'notif.mail_booking_pending.text': 'การจองที่ส่งต่อซึ่งรอคุณอยู่: {count}',
|
||||
'notif.mail_ingest_paused.title': 'หยุดการนำเข้าอีเมลชั่วคราว',
|
||||
'notif.mail_ingest_paused.text': 'ขณะนี้ยังไม่รับอีเมลการจองที่ส่งต่อมา ที่อยู่ของคุณยังคงอยู่และจะใช้งานได้อีกครั้งเมื่อการนำเข้ากลับมา',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'ขณะนี้ยังไม่รับอีเมลการจองที่ส่งต่อมา ที่อยู่ของคุณยังคงอยู่และจะใช้งานได้อีกครั้งเมื่อการนำเข้ากลับมา',
|
||||
'notif.action.undo': 'เลิกทำ',
|
||||
'notif.action.keep': 'เก็บไว้',
|
||||
'notif.action.review': 'ตรวจสอบ',
|
||||
|
||||
@@ -62,7 +62,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'İncelenecek iletilen rezervasyonlar',
|
||||
'notif.mail_booking_pending.text': 'Seni bekleyen iletilen rezervasyonlar: {count}',
|
||||
'notif.mail_ingest_paused.title': 'E-posta içe aktarımı duraklatıldı',
|
||||
'notif.mail_ingest_paused.text': 'İletilen rezervasyon e-postaları şimdilik kabul edilmiyor. Adreslerin kalıyor ve içe aktarım geri geldiğinde yeniden çalışacak.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'İletilen rezervasyon e-postaları şimdilik kabul edilmiyor. Adreslerin kalıyor ve içe aktarım geri geldiğinde yeniden çalışacak.',
|
||||
'notif.action.undo': 'Geri al',
|
||||
'notif.action.keep': 'Tut',
|
||||
'notif.action.review': 'İncele',
|
||||
|
||||
@@ -63,7 +63,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Переслані бронювання для перевірки',
|
||||
'notif.mail_booking_pending.text': 'Пересланих бронювань чекає на вас: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Імпорт листів призупинено',
|
||||
'notif.mail_ingest_paused.text': 'Переслані листи з бронюваннями поки що не приймаються. Ваші адреси зберігаються й знову працюватимуть, коли імпорт повернеться.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Переслані листи з бронюваннями поки що не приймаються. Ваші адреси зберігаються й знову працюватимуть, коли імпорт повернеться.',
|
||||
'notif.action.undo': 'Скасувати',
|
||||
'notif.action.keep': 'Залишити',
|
||||
'notif.action.review': 'Перевірити',
|
||||
|
||||
@@ -60,7 +60,8 @@ const notif: TranslationStrings = {
|
||||
'notif.mail_booking_pending.title': 'Đặt chỗ chuyển tiếp cần xem lại',
|
||||
'notif.mail_booking_pending.text': 'Đặt chỗ chuyển tiếp đang chờ bạn: {count}',
|
||||
'notif.mail_ingest_paused.title': 'Đã tạm dừng nhập email',
|
||||
'notif.mail_ingest_paused.text': 'Hiện tại email đặt chỗ được chuyển tiếp chưa được nhận. Địa chỉ của bạn vẫn được giữ và sẽ hoạt động lại khi tính năng nhập quay lại.',
|
||||
'notif.mail_ingest_paused.text':
|
||||
'Hiện tại email đặt chỗ được chuyển tiếp chưa được nhận. Địa chỉ của bạn vẫn được giữ và sẽ hoạt động lại khi tính năng nhập quay lại.',
|
||||
'notif.action.undo': 'Hoàn tác',
|
||||
'notif.action.keep': 'Giữ lại',
|
||||
'notif.action.review': 'Xem lại',
|
||||
|
||||
@@ -140,10 +140,14 @@ describe('mail-ingest rows', () => {
|
||||
});
|
||||
|
||||
it('MAILC-016: the connection test names its transport and what failed', () => {
|
||||
expect(mailIngestAdminTestResponseSchema.safeParse({ transport: 'imap', ok: true, error: null }).success).toBe(true);
|
||||
expect(mailIngestAdminTestResponseSchema.safeParse({ transport: 'imap', ok: true, error: null }).success).toBe(
|
||||
true,
|
||||
);
|
||||
const failed = { transport: 'webhook', ok: false, error: 'No webhook secret is set' };
|
||||
expect(mailIngestAdminTestResponseSchema.safeParse(failed).success).toBe(true);
|
||||
expect(mailIngestAdminTestResponseSchema.safeParse({ transport: 'smtp', ok: true, error: null }).success).toBe(false);
|
||||
expect(mailIngestAdminTestResponseSchema.safeParse({ transport: 'smtp', ok: true, error: null }).success).toBe(
|
||||
false,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user