|
@@ -764,18 +764,23 @@ serve(wrapHandler('shoprenter-sync', async (req) => {
|
|
|
console.log(`[ShopRenter] Starting full sync for store ${storeId}`)
|
|
console.log(`[ShopRenter] Starting full sync for store ${storeId}`)
|
|
|
|
|
|
|
|
// Check data access permissions
|
|
// Check data access permissions
|
|
|
- const permissions = store.data_access_permissions || {}
|
|
|
|
|
- const canSyncProducts = permissions.allow_product_access !== false
|
|
|
|
|
- const canSyncOrders = permissions.allow_order_access !== false
|
|
|
|
|
- const canSyncCustomers = permissions.allow_customer_access !== false
|
|
|
|
|
- const qdrantEnabled = store.qdrant_sync_enabled !== false
|
|
|
|
|
|
|
+ // Get access policies from store_sync_config
|
|
|
|
|
+ const { data: syncConfig } = await supabase
|
|
|
|
|
+ .from('store_sync_config')
|
|
|
|
|
+ .select('products_access_policy, orders_access_policy, customers_access_policy')
|
|
|
|
|
+ .eq('store_id', store_id)
|
|
|
|
|
+ .single()
|
|
|
|
|
|
|
|
- // Check store_sync_config for orders/customers sync flags
|
|
|
|
|
- const syncConfig = (store as any).store_sync_config?.[0] || {}
|
|
|
|
|
- const shouldSyncOrders = syncConfig.sync_orders !== false // Default to true if not explicitly disabled
|
|
|
|
|
- const shouldSyncCustomers = syncConfig.sync_customers !== false // Default to true if not explicitly disabled
|
|
|
|
|
|
|
+ // Only sync if policy is 'sync' (not 'api_only' or 'not_allowed')
|
|
|
|
|
+ const canSyncProducts = syncConfig?.products_access_policy === 'sync'
|
|
|
|
|
+ const canSyncOrders = syncConfig?.orders_access_policy === 'sync'
|
|
|
|
|
+ const canSyncCustomers = syncConfig?.customers_access_policy === 'sync'
|
|
|
|
|
+ const qdrantEnabled = store.qdrant_sync_enabled !== false
|
|
|
|
|
|
|
|
console.log('[ShopRenter] Sync permissions:', {
|
|
console.log('[ShopRenter] Sync permissions:', {
|
|
|
|
|
+ productsPolicy: syncConfig?.products_access_policy || 'not_configured',
|
|
|
|
|
+ ordersPolicy: syncConfig?.orders_access_policy || 'not_configured',
|
|
|
|
|
+ customersPolicy: syncConfig?.customers_access_policy || 'not_configured',
|
|
|
products: canSyncProducts,
|
|
products: canSyncProducts,
|
|
|
orders: canSyncOrders,
|
|
orders: canSyncOrders,
|
|
|
customers: canSyncCustomers,
|
|
customers: canSyncCustomers,
|