BugFix downloader, add IAM User to send EMails for a specific Domain
This commit is contained in:
@@ -274,7 +274,7 @@ def delete_s3_emails(s3_client, bucket, emails_to_delete, email_info):
|
||||
|
||||
return deleted_count
|
||||
|
||||
def process_domain(domain_name, domain_config, last_sync):
|
||||
def process_domain(domain_name, domain_config, last_sync, all_domains_config):
|
||||
"""Verarbeitet eine einzelne Domain"""
|
||||
bucket = domain_config["bucket"]
|
||||
prefix = domain_config["prefix"]
|
||||
@@ -344,28 +344,34 @@ def process_domain(domain_name, domain_config, last_sync):
|
||||
}
|
||||
|
||||
# Alle Domains-Konfigurationen für die Validierung verwenden
|
||||
is_valid, recipient_domain = is_valid_recipient(to_address, {domain_name: domain_config})
|
||||
# BUGFIX: Hier prüfen wir gegen ALLE konfigurierten Domains
|
||||
is_valid, recipient_domain = is_valid_recipient(to_address, all_domains_config)
|
||||
|
||||
if is_valid:
|
||||
logger.info(f"Gültige E-Mail für: {to_address}")
|
||||
|
||||
# E-Mail speichern
|
||||
if store_email(email_content, to_address, message_id, key, MAIL_DIR):
|
||||
# Status aktualisieren
|
||||
last_sync[sync_key] = {
|
||||
'timestamp': time.time(),
|
||||
'to': to_address,
|
||||
'message_id': message_id,
|
||||
'domain': domain_name,
|
||||
'bucket': bucket
|
||||
}
|
||||
new_emails += 1
|
||||
logger.info(f"E-Mail {key} erfolgreich synchronisiert ({new_emails})")
|
||||
|
||||
# Status nach jeweils 10 E-Mails speichern
|
||||
if new_emails % 10 == 0:
|
||||
save_sync_status(last_sync)
|
||||
logger.info(f"Zwischenspeicherung: {new_emails} neue E-Mails bisher")
|
||||
# Nur speichern, wenn die E-Mail zur aktuellen Domain gehört
|
||||
if recipient_domain == domain_name:
|
||||
# E-Mail speichern
|
||||
if store_email(email_content, to_address, message_id, key, MAIL_DIR):
|
||||
# Status aktualisieren
|
||||
last_sync[sync_key] = {
|
||||
'timestamp': time.time(),
|
||||
'to': to_address,
|
||||
'message_id': message_id,
|
||||
'domain': domain_name,
|
||||
'bucket': bucket
|
||||
}
|
||||
new_emails += 1
|
||||
logger.info(f"E-Mail {key} erfolgreich synchronisiert ({new_emails})")
|
||||
|
||||
# Status nach jeweils 10 E-Mails speichern
|
||||
if new_emails % 10 == 0:
|
||||
save_sync_status(last_sync)
|
||||
logger.info(f"Zwischenspeicherung: {new_emails} neue E-Mails bisher")
|
||||
else:
|
||||
# Gültige E-Mail, aber für eine andere Domain - nicht löschen!
|
||||
logger.info(f"E-Mail {key} ist für Domain {recipient_domain}, wird übersprungen (nicht gelöscht)")
|
||||
else:
|
||||
logger.info(f"Ungültige Empfängeradresse: {to_address} für {key}")
|
||||
emails_to_delete.append(key)
|
||||
@@ -415,7 +421,8 @@ def main():
|
||||
total_all_emails = 0
|
||||
|
||||
for domain_name, domain_config in domains_config.items():
|
||||
new_emails, all_emails = process_domain(domain_name, domain_config, last_sync)
|
||||
# BUGFIX: all_domains_config übergeben statt nur der aktuellen Domain-Konfiguration
|
||||
new_emails, all_emails = process_domain(domain_name, domain_config, last_sync, domains_config)
|
||||
total_new_emails += new_emails
|
||||
total_all_emails += all_emails
|
||||
|
||||
|
||||
Reference in New Issue
Block a user