changed blocked sender list
This commit is contained in:
parent
c826d4c299
commit
56c7b51e35
|
|
@ -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,10 +42,10 @@ export class BlocklistChecker {
|
||||||
let isBlocked = false;
|
let isBlocked = false;
|
||||||
|
|
||||||
for (const pattern of patterns) {
|
for (const pattern of patterns) {
|
||||||
|
for (const senderClean of sendersClean) {
|
||||||
if (picomatch.isMatch(senderClean, pattern.toLowerCase())) {
|
if (picomatch.isMatch(senderClean, pattern.toLowerCase())) {
|
||||||
log(
|
log(
|
||||||
`⛔ BLOCKED: Sender ${senderClean} matches pattern '${pattern}' ` +
|
`⛔ BLOCKED: Sender ${senderClean} matches pattern '${pattern}' for inbox ${recipient}`,
|
||||||
`for inbox ${recipient}`,
|
|
||||||
'WARNING',
|
'WARNING',
|
||||||
workerName,
|
workerName,
|
||||||
);
|
);
|
||||||
|
|
@ -53,10 +53,10 @@ export class BlocklistChecker {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isBlocked) break;
|
||||||
|
}
|
||||||
result[recipient] = isBlocked;
|
result[recipient] = isBlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue