feat(api): allow routing all email through fallback (#3509)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-17 04:16:08 +02:00
1 parent d564e01518
commit 2d8d130be1
5 files changed
+27 -3

No files matched your search

+4 -1
View File
@@ -379,8 +379,11 @@ function normalizeEmailFallbackConfig(config: MasterConfig): void {
assertIntegerInRange(port, 'FLUXER_EMAIL_FALLBACK_SMTP_PORT', 1, 65_535);
validateSmtpHeaders(smtp.headers, 'FLUXER_EMAIL_FALLBACK_SMTP_HEADERS');
const normalizedDomains = domains.map((domain) => domain.trim().toLowerCase());
if (normalizedDomains.includes('*') && new Set(normalizedDomains).size > 1) {
throw new Error('FLUXER_EMAIL_FALLBACK_DOMAINS must be either * or a list of domains');
}
for (const domain of normalizedDomains) {
if (!EMAIL_DOMAIN_PATTERN.test(domain)) {
if (domain !== '*' && !EMAIL_DOMAIN_PATTERN.test(domain)) {
throw new Error(
`FLUXER_EMAIL_FALLBACK_DOMAINS entry ${JSON.stringify(domain)} must be a domain such as gmail.com`,
);
@@ -540,6 +540,17 @@ describe('ConfigLoader', () => {
},
);
test('loads * as the email fallback domains', async () => {
stubMinimalEnv({...emailFallbackEnv, FLUXER_EMAIL_FALLBACK_DOMAINS: ' * '});
const config = await loadConfig();
expect(config.integrations.email.fallback?.domains).toEqual(['*']);
});
test('rejects * mixed with email fallback domains', async () => {
stubMinimalEnv({...emailFallbackEnv, FLUXER_EMAIL_FALLBACK_DOMAINS: '*,gmail.com'});
await expect(loadConfig()).rejects.toThrow('FLUXER_EMAIL_FALLBACK_DOMAINS must be either * or a list of domains');
});
test('loads the email fallback headers', async () => {
stubMinimalEnv({...emailFallbackEnv, FLUXER_EMAIL_FALLBACK_SMTP_HEADERS: '{"X-Tracking":"{\\"enable\\":0}"}'});
const config = await loadConfig();