The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(mail-ingest): read a transfer booking with a numeric code instead of filing it as a forwarding confirmation
Maurice5e8cc0b90af3
diff --git a/server/src/nest/mail-ingest/mail-classify.ts b/server/src/nest/mail-ingest/mail-classify.tsindex 32be0b2c8..336d27720 100644--- a/server/src/nest/mail-ingest/mail-classify.ts+++ b/server/src/nest/mail-ingest/mail-classify.ts@@ -13,6 +13,9 @@ type MailClass =const FORWARDING_SENDERS = /forwarding-noreply@google\.com|@accountprotection\.microsoft\.com|@microsoft\.com/i;const FORWARDING_WORD = /forwarding|weiterleitung|transfert|reenv[ií]o|inoltro|doorsturen/i;+/** The forwarding words that name mail forwarding alone: a bare "transfert" is as often an airport transfer. */+const MAIL_FORWARDING_WORD =+ /forwarding|weiterleitung|transfert (?:de |des |du )?(?:courriers?|messages?|e-?mails?|mails?)|transfert automatique|reenv[ií]o|inoltro|doorsturen/i;const CONFIRM_WORD = /confirm|bestätig|verif|conferma|bevestig/i;const CODE_RE = /(?:code|código|codice|kód)\D{0,40}?(\d{6,10})\b/i;const AUTO_REPLY_SUBJECT =@@ -33,7 +36,7 @@ export function classifyMail(mail: WalkedMail): MailClass {const code = CODE_RE.exec(mail.body)?.[1] ?? null;// A subject alone is no proof: "Votre transfert aéroport est confirmé" is a booking.const fromProvider = FORWARDING_SENDERS.test(envelope.from ?? '');- const subjectSays = asksToConfirmForwarding(subject);+ const subjectSays = asksToConfirmForwarding(subject, fromProvider ? FORWARDING_WORD : MAIL_FORWARDING_WORD);if (fromProvider ? subjectSays || code !== null : subjectSays && code !== null) {return { kind: 'forwarding_confirmation', code };}@@ -53,8 +56,8 @@ export function classifyMail(mail: WalkedMail): MailClass {}/** A forwarding word with a confirm word after it, found without rescanning the subject from every forwarding word. */-function asksToConfirmForwarding(subject: string): boolean {- const word = FORWARDING_WORD.exec(subject);+function asksToConfirmForwarding(subject: string, forwardingWord: RegExp): boolean {+ const word = forwardingWord.exec(subject);return word !== null && CONFIRM_WORD.test(subject.slice(word.index + word[0].length));}diff --git a/server/tests/unit/nest/mail-ingest/mail-ingest-helpers.test.ts b/server/tests/unit/nest/mail-ingest/mail-ingest-helpers.test.tsindex 89e059a56..9236ccbd1 100644--- a/server/tests/unit/nest/mail-ingest/mail-ingest-helpers.test.ts+++ b/server/tests/unit/nest/mail-ingest/mail-ingest-helpers.test.ts@@ -51,6 +51,13 @@ describe('classifyMail', () => {]) {expect(classifyMail(mail({ Subject: subject }, body)), subject).toEqual({ kind: 'read' });}+ const coded = mail(+ { From: '[email protected]', Subject: 'Transfert Orly - Paris : confirmation de réservation' },+ 'Votre code de réservation : 58213467. Rendez-vous le 2030-03-02 à 10:00.',+ );+ expect(classifyMail(coded)).toEqual({ kind: 'read' });+ const relayed = mail({ Subject: 'Transfert de courrier : confirmez' }, 'Votre code : 612345678');+ expect(classifyMail(relayed)).toEqual({ kind: 'forwarding_confirmation', code: '612345678' });});it('reads a long subject and From header in linear time', () => {