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)

View File

@@ -151,9 +151,10 @@ def wordpress_status_webhook(request):
if post_url:
content.external_url = post_url
# Only update IGNY8 status if WordPress status changed from draft to publish
if post_status == 'publish' and old_status != 'published':
content.status = 'published'
# FIXED: Always update status when WordPress status differs
if content.status != igny8_status:
content.status = igny8_status
logger.info(f"[wordpress_status_webhook] Status updated: {old_status}{content.status}")
# Update WordPress status in metadata
if not content.metadata: