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) <noreply@anthropic.com>
This commit is contained in:
2026-03-30 10:25:38 +00:00
parent 2cbb9aaa65
commit fc28ef2d7c
+5
View File
@@ -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',