fix(connector): [31e88f42] Implement de-duplication for contact.created
SuperOffice sends two 'contact.created' webhooks for a single new contact. This caused the connector to process the same entity twice, leading to duplicate entries and logs. This commit introduces a de-duplication shield in the worker: - A new method is added to to check for jobs with the same company name that are either 'PROCESSING' or 'COMPLETED' within the last 5 minutes. - The worker now fetches the company name upon receiving a job, updates the job record with the name, and then calls the new de-duplication method. - If a duplicate event is detected, the job is skipped, preventing redundant processing.
This commit is contained in:
@@ -189,6 +189,13 @@ def process_job(job, so_client: SuperOfficeClient, queue: JobQueue):
|
||||
assoc = contact_details.get("Associate") or {}
|
||||
aname = assoc.get("Name", "").upper().strip()
|
||||
queue.update_entity_name(job['id'], crm_name, associate_name=aname)
|
||||
|
||||
# --- DE-DUPLICATION SHIELD (Added March 2026) ---
|
||||
if "contact.created" in event_low:
|
||||
if queue.check_for_recent_duplicate(crm_name, job['id']):
|
||||
msg = f"Duplicate 'contact.created' event for '{crm_name}'. This job will be skipped."
|
||||
logger.info(f"🛡️ {msg}")
|
||||
return ("SKIPPED", msg)
|
||||
|
||||
# ROBOPLANET FILTER
|
||||
is_robo = False
|
||||
|
||||
Reference in New Issue
Block a user