mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 22:57:32 +00:00
fix(mail-ingest): Outlook HTML forwards, the default AI limit, secret env vars, and the pipeline tests
- mime-walker: trim each line of a stripped HTML body, so the space a tag leaves is not read as a folded header line that swallows the booking under an Outlook forward's header block. - settings: an unset daily AI limit is the default of ten, not zero (Number(null) is 0), which kept the AI from ever reading a mail. - env: MAIL_INGEST_IMAP_PASS and MAIL_INGEST_WEBHOOK_SECRET are secrets and never printed in the boot report. - pipeline test: the subject is kept without its forward prefixes, the demo move adds its booking before the second trip exists, the typed notification mock, and AI reading stays offered while the person switched it off. - e2e: the pipeline tick runs in a request context of its own, as the cron registrar runs it, and the 401 checks run without awaiting in a loop.
This commit is contained in:
@@ -33,6 +33,8 @@ export const SECRET_ENV_KEYS: ReadonlySet<string> = new Set([
|
||||
'MAPBOX_ACCESS_TOKEN',
|
||||
'CARTO_API_KEY',
|
||||
'DEMO_ADMIN_PASS',
|
||||
'MAIL_INGEST_IMAP_PASS',
|
||||
'MAIL_INGEST_WEBHOOK_SECRET',
|
||||
]);
|
||||
|
||||
/** How a variable's value appears in the boot report. */
|
||||
|
||||
@@ -284,9 +284,20 @@ function safeFileName(name: string, kind: MailAttachmentKind, position: number):
|
||||
/** Line breaks and block ends, so the header lines of a forwarded HTML mail stay lines without their tags. */
|
||||
const HTML_LINE_BREAK = /<(?:br|hr)\b[^>]*>|<\/(?:p|div|tr|li|h[1-6]|blockquote|table)\s*>/gi;
|
||||
|
||||
/** A section as text: its HTML stripped when it has a readable one, else its plain text. */
|
||||
/**
|
||||
* A section as text: its HTML stripped when it has a readable one, else its plain text.
|
||||
* Each line of the HTML is trimmed: a stripped tag leaves a space in front of a
|
||||
* line, which the forward unwrapping would read as a folded header continuation,
|
||||
* dropping the booking under a forwarded header block with it. HTML folds no headers.
|
||||
*/
|
||||
function sectionText(section: Section): string {
|
||||
const html = section.html === null ? '' : stripMarkup(section.html.replace(HTML_LINE_BREAK, '\n'));
|
||||
const html =
|
||||
section.html === null
|
||||
? ''
|
||||
: stripMarkup(section.html.replace(HTML_LINE_BREAK, '\n'))
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.join('\n');
|
||||
return html || (section.text === null ? '' : collapseWhitespace(section.text));
|
||||
}
|
||||
|
||||
|
||||
@@ -100,8 +100,10 @@ export class MailIngestSettingsService {
|
||||
return this.config.webhookSecret ?? (decrypt_api_key(stored) || null);
|
||||
}
|
||||
|
||||
/** The AI reads a person gets a day; an unset or blank setting is the default, not zero (`Number('')` is 0). */
|
||||
async aiDailyCap(): Promise<number> {
|
||||
const value = Number(await this.settings.getAppSetting('mail_ingest_ai_per_user_daily'));
|
||||
const stored = (await this.settings.getAppSetting('mail_ingest_ai_per_user_daily'))?.trim();
|
||||
const value = stored ? Number(stored) : Number.NaN;
|
||||
return Number.isInteger(value) && value >= 0 ? value : DEFAULT_AI_PER_USER_DAILY;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user