fix: Typ-Generic in checkSuppression, SMTP_PASS Fallback, Logging-Test prüft console.error, tenantId-Fehler-Test

This commit is contained in:
2026-04-17 10:53:56 +00:00
parent a60b08876c
commit 5340e76630
4 changed files with 15 additions and 5 deletions

View File

@@ -42,4 +42,10 @@ describe('checkSuppression', () => {
expect(call[0]).toContain('$1')
expect(call[1]).toEqual(['x@x.com'])
})
it('propagiert Fehler bei ungültiger tenantId nach oben', async () => {
const { withTenant } = await import('../db/tenant')
vi.mocked(withTenant).mockRejectedValueOnce(new Error('Ungültige tenantId'))
await expect(checkSuppression('invalid!', 'x@x.com')).rejects.toThrow('Ungültige tenantId')
})
})

View File

@@ -3,7 +3,10 @@ import { withTenant } from '../db/tenant'
export async function checkSuppression(tenantId: string, email: string): Promise<boolean> {
const normalized = email.toLowerCase().trim()
const rows = await withTenant(tenantId, (client) =>
client.query('SELECT 1 FROM suppression_list WHERE email = $1 LIMIT 1', [normalized])
client.query<{ '?column?': number }>(
'SELECT 1 FROM suppression_list WHERE email = $1 LIMIT 1',
[normalized]
)
)
return rows.length > 0
}