changed blocked sender list

This commit is contained in:
Andreas Knuth 2026-03-07 15:01:56 -06:00
parent c826d4c299
commit 56c7b51e35
2 changed files with 26 additions and 18 deletions

View File

@ -26,15 +26,15 @@ export class BlocklistChecker {
* Batch-check whether a sender is blocked for each recipient. * Batch-check whether a sender is blocked for each recipient.
* Uses a single batch DynamoDB call for efficiency. * Uses a single batch DynamoDB call for efficiency.
*/ */
async batchCheckBlockedSenders( async batchCheckBlockedSenders(
recipients: string[], recipients: string[],
sender: string, senders: string[], // <-- Geändert zu Array
workerName: string, workerName: string,
): Promise<Record<string, boolean>> { ): Promise<Record<string, boolean>> {
const patternsByRecipient = const patternsByRecipient = await this.dynamodb.batchGetBlockedPatterns(recipients);
await this.dynamodb.batchGetBlockedPatterns(recipients);
const senderClean = extractAddress(sender); // Alle übergebenen Adressen bereinigen
const sendersClean = senders.map(s => extractAddress(s)).filter(Boolean);
const result: Record<string, boolean> = {}; const result: Record<string, boolean> = {};
for (const recipient of recipients) { for (const recipient of recipients) {
@ -42,21 +42,21 @@ export class BlocklistChecker {
let isBlocked = false; let isBlocked = false;
for (const pattern of patterns) { for (const pattern of patterns) {
if (picomatch.isMatch(senderClean, pattern.toLowerCase())) { for (const senderClean of sendersClean) {
log( if (picomatch.isMatch(senderClean, pattern.toLowerCase())) {
`⛔ BLOCKED: Sender ${senderClean} matches pattern '${pattern}' ` + log(
`for inbox ${recipient}`, `⛔ BLOCKED: Sender ${senderClean} matches pattern '${pattern}' for inbox ${recipient}`,
'WARNING', 'WARNING',
workerName, workerName,
); );
isBlocked = true; isBlocked = true;
break; break;
}
} }
if (isBlocked) break;
} }
result[recipient] = isBlocked; result[recipient] = isBlocked;
} }
return result; return result;
} }
} }

View File

@ -179,9 +179,17 @@ export class MessageProcessor {
} }
// 6. BLOCKLIST CHECK // 6. BLOCKLIST CHECK
const sendersToCheck: string[] = [];
if (fromAddrFinal) sendersToCheck.push(fromAddrFinal);
const headerFrom = parsedFinal?.from?.text;
if (headerFrom && !sendersToCheck.includes(headerFrom)) {
sendersToCheck.push(headerFrom);
}
const blockedByRecipient = await this.blocklist.batchCheckBlockedSenders( const blockedByRecipient = await this.blocklist.batchCheckBlockedSenders(
recipients, recipients,
fromAddrFinal, sendersToCheck, // <-- Array übergeben
workerName, workerName,
); );