Compare commits
2 Commits
27c2be664a
...
contabo
| Author | SHA1 | Date | |
|---|---|---|---|
| 9862689c0c | |||
| bed6c2a398 |
@@ -53,7 +53,6 @@ def get_queue_url(domain):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
def publish_to_sns(topic_arn, message_body, msg_id):
|
def publish_to_sns(topic_arn, message_body, msg_id):
|
||||||
"""Versucht SNS Publish. Gibt True bei Erfolg, False bei Topic-Not-Found."""
|
|
||||||
attempt = 0
|
attempt = 0
|
||||||
while attempt < MAX_RETRIES:
|
while attempt < MAX_RETRIES:
|
||||||
try:
|
try:
|
||||||
@@ -65,8 +64,9 @@ def publish_to_sns(topic_arn, message_body, msg_id):
|
|||||||
return True
|
return True
|
||||||
except ClientError as e:
|
except ClientError as e:
|
||||||
error_code = e.response['Error']['Code']
|
error_code = e.response['Error']['Code']
|
||||||
if error_code == 'NotFound' or error_code == 'NotFoundException':
|
# Fallback auf SQS bei Topic-nicht-gefunden ODER fehlender Berechtigung
|
||||||
logger.info(f"ℹ️ SNS Topic not found for {topic_arn} — falling back to SQS")
|
if error_code in ('NotFound', 'NotFoundException', 'AuthorizationError'):
|
||||||
|
logger.info(f"ℹ️ SNS unavailable for {topic_arn} ({error_code}) — falling back to SQS")
|
||||||
return False
|
return False
|
||||||
attempt += 1
|
attempt += 1
|
||||||
logger.warning(f"Retry {attempt}/{MAX_RETRIES} SNS: {error_code}")
|
logger.warning(f"Retry {attempt}/{MAX_RETRIES} SNS: {error_code}")
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import { BlocklistChecker } from '../email/blocklist.js';
|
|||||||
import { BounceHandler } from '../email/bounce-handler.js';
|
import { BounceHandler } from '../email/bounce-handler.js';
|
||||||
import { parseEmail, isProcessedByWorker } from '../email/parser.js';
|
import { parseEmail, isProcessedByWorker } from '../email/parser.js';
|
||||||
import { RulesProcessor } from '../email/rules-processor.js';
|
import { RulesProcessor } from '../email/rules-processor.js';
|
||||||
|
import { config } from '../config.js';
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Processor
|
// Processor
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -258,7 +258,8 @@ export class MessageProcessor {
|
|||||||
|
|
||||||
if (totalHandled === recipients.length) {
|
if (totalHandled === recipients.length) {
|
||||||
if (blockedRecipients.length === recipients.length) {
|
if (blockedRecipients.length === recipients.length) {
|
||||||
// All blocked
|
// All blocked — im Standby kein S3 anfassen
|
||||||
|
if (!config.standbyMode) {
|
||||||
try {
|
try {
|
||||||
await this.s3.markAsBlocked(
|
await this.s3.markAsBlocked(
|
||||||
domain,
|
domain,
|
||||||
@@ -272,14 +273,18 @@ export class MessageProcessor {
|
|||||||
log(`⚠ Failed to handle blocked email: ${err.message ?? err}`, 'ERROR', workerName);
|
log(`⚠ Failed to handle blocked email: ${err.message ?? err}`, 'ERROR', workerName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (successful.length > 0) {
|
} else if (successful.length > 0) {
|
||||||
|
if (!config.standbyMode) {
|
||||||
await this.s3.markAsProcessed(
|
await this.s3.markAsProcessed(
|
||||||
domain,
|
domain,
|
||||||
messageId,
|
messageId,
|
||||||
workerName,
|
workerName,
|
||||||
failedPermanent.length > 0 ? failedPermanent : undefined,
|
failedPermanent.length > 0 ? failedPermanent : undefined,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
} else if (failedPermanent.length > 0) {
|
} else if (failedPermanent.length > 0) {
|
||||||
|
if (!config.standbyMode) {
|
||||||
await this.s3.markAsAllInvalid(
|
await this.s3.markAsAllInvalid(
|
||||||
domain,
|
domain,
|
||||||
messageId,
|
messageId,
|
||||||
@@ -287,6 +292,7 @@ export class MessageProcessor {
|
|||||||
workerName,
|
workerName,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Summary
|
// Summary
|
||||||
const parts: string[] = [];
|
const parts: string[] = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user