1
This commit is contained in:
@@ -217,26 +217,53 @@ class IntegrationService:
|
||||
config = integration.config_json
|
||||
credentials = integration.get_credentials()
|
||||
|
||||
# Try to get site URL from multiple sources
|
||||
site_url = config.get('site_url')
|
||||
username = credentials.get('username')
|
||||
app_password = credentials.get('app_password')
|
||||
|
||||
# Fallback to legacy wp_url if available
|
||||
if not site_url and integration.site.wp_url:
|
||||
site_url = integration.site.wp_url
|
||||
logger.info(f"[IntegrationService] Using legacy wp_url for integration {integration.id}: {site_url}")
|
||||
|
||||
# Fallback to domain field
|
||||
if not site_url and integration.site.domain:
|
||||
site_url = integration.site.domain
|
||||
logger.info(f"[IntegrationService] Using domain for integration {integration.id}: {site_url}")
|
||||
|
||||
if not site_url:
|
||||
return {
|
||||
'success': False,
|
||||
'message': 'WordPress site URL not configured',
|
||||
'details': {}
|
||||
'message': 'WordPress site URL not configured. Please set the site URL in integration config, site domain, or legacy wp_url field.',
|
||||
'details': {
|
||||
'integration_id': integration.id,
|
||||
'site_id': integration.site.id,
|
||||
'site_name': integration.site.name
|
||||
}
|
||||
}
|
||||
|
||||
username = credentials.get('username')
|
||||
app_password = credentials.get('app_password')
|
||||
|
||||
try:
|
||||
client = WordPressClient(site_url, username, app_password)
|
||||
result = client.test_connection()
|
||||
|
||||
# If connection successful and site_url wasn't in config, save it
|
||||
if result.get('success') and not config.get('site_url'):
|
||||
config['site_url'] = site_url
|
||||
integration.config_json = config
|
||||
integration.save(update_fields=['config_json'])
|
||||
logger.info(f"[IntegrationService] Saved site_url to integration {integration.id} config: {site_url}")
|
||||
|
||||
return result
|
||||
except Exception as e:
|
||||
return {
|
||||
'success': False,
|
||||
'message': f'WordPress connection failed: {str(e)}',
|
||||
'details': {}
|
||||
'details': {
|
||||
'site_url': site_url,
|
||||
'error': str(e)
|
||||
}
|
||||
}
|
||||
|
||||
def _test_shopify_connection(
|
||||
|
||||
Reference in New Issue
Block a user