diff --git a/connector-superoffice/worker.py b/connector-superoffice/worker.py index e4d81787..190ee764 100644 --- a/connector-superoffice/worker.py +++ b/connector-superoffice/worker.py @@ -45,26 +45,29 @@ def process_job(job, so_client: SuperOfficeClient, queue: JobQueue): Returns: (STATUS, MESSAGE) STATUS: 'SUCCESS', 'SKIPPED', 'DELETED', 'RETRY', 'FAILED' """ - logger.info(f"--- [WORKER v1.9.8 - THE FORTRESS] Processing Job {job['id']} ({job['event_type']}) ---") + logger.info(f"--- [WORKER v1.9.9 - ABSOLUTE FILTERS] Processing Job {job['id']} ({job['event_type']}) ---") payload = job['payload'] event_low = job['event_type'].lower() - # --- NOISE REDUCTION: STRICT STAMMDATEN FILTER --- - # We ONLY react to changes in critical fields. Our own UDF updates must be ignored. + # --- NOISE REDUCTION: STRICT STAMMDATEN FILTER (v1.9.9) --- + # We ONLY react to changes in critical fields. + # For .created events, we also check if name/urladdress are explicitly in the payload changes. changes = [c.lower() for c in payload.get("Changes", [])] - if "contact.changed" in event_low: - if "name" not in changes and "urladdress" not in changes: - msg = f"Skipping contact change: No changes to name or website in {changes}." + # RULE: If it's a person event, we ONLY care if name, email, or jobtitle changed (for role mapping). + # If it's a contact event, we ONLY care if name or website changed. + if "person" in event_low: + if "name" not in changes and "email" not in changes and "jobtitle" not in changes and "contact_id" not in changes: + msg = f"Skipping person event: No relevant changes (Name/Email/JobTitle/Mapping) in {changes}." logger.info(f"⏭️ {msg}") return ("SKIPPED", msg) - if "person.changed" in event_low: - if "jobtitle" not in changes and "contact_id" not in changes: - msg = f"Skipping person change: No changes to jobtitle or contact mapping in {changes}." + elif "contact" in event_low: + if "name" not in changes and "urladdress" not in changes: + msg = f"Skipping contact event: No relevant changes (Name/Website) in {changes}." logger.info(f"⏭️ {msg}") return ("SKIPPED", msg) - # ------------------------------------------------- + # --------------------------------------------------------- # --- CIRCUIT BREAKER: DETECT ECHOES ---