refactors

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-01 03:42:31 +00:00
parent 861ca016aa
commit 55a00bf1ad
7 changed files with 498 additions and 18 deletions

View File

@@ -223,17 +223,24 @@ class IntegrationViewSet(SiteSectorModelViewSet):
Request body:
{
"direction": "both", # 'both', 'to_external', 'from_external'
"direction": "metadata", # 'metadata', 'both', 'to_external', 'from_external'
"content_types": ["blog_post", "page"] # Optional
}
"""
integration = self.get_object()
direction = request.data.get('direction', 'both')
direction = request.data.get('direction', 'metadata')
content_types = request.data.get('content_types')
sync_service = SyncService()
result = sync_service.sync(integration, direction=direction, content_types=content_types)
# Handle metadata-only sync (for "Sync Now" button)
if direction == 'metadata':
from igny8_core.business.integration.services.sync_metadata_service import SyncMetadataService
metadata_service = SyncMetadataService()
result = metadata_service.sync_wordpress_structure(integration)
else:
# Full content sync (legacy behavior)
sync_service = SyncService()
result = sync_service.sync(integration, direction=direction, content_types=content_types)
response_status = status.HTTP_200_OK if result.get('success') else status.HTTP_400_BAD_REQUEST
return success_response(result, request=request, status_code=response_status)