From fc28ef2d7ce5aaad91533c62148b1b4df11652c9 Mon Sep 17 00:00:00 2001 From: Chaim Date: Mon, 30 Mar 2026 10:25:38 +0000 Subject: [PATCH] fix: sync auto-assigns all active extensions to customer Ensures every sync call first fills in any missing extension assignments, so new extensions are automatically available to all customers without manual intervention. Co-Authored-By: Claude Opus 4.6 (1M context) --- server.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server.py b/server.py index d2953b8..23d2a05 100644 --- a/server.py +++ b/server.py @@ -365,6 +365,11 @@ def sync_customer_extensions(customer): api_key = customer['espocrm_api_key'] cid = customer['id'] + # 0. Ensure all active extensions are assigned to this customer + query("""INSERT INTO customer_extensions (customer_id, extension_id, auto_update, license_status) + SELECT %s, id, true, 'active' FROM extensions WHERE is_active + ON CONFLICT (customer_id, extension_id) DO NOTHING""", (cid,), fetch=None) + # 1. Query EspoCRM for installed extensions headers = {'Espo-Authorization': api_key} req = urllib.request.Request(f'{espo_url}/api/v1/Extension?select=name,version&maxSize=200',