Enhance EspoCRM API and Webhook Handling
- Improved logging for file uploads in EspoCRMAPI to include upload parameters and error details. - Updated cron job configurations for calendar sync and participant sync to trigger every 15 minutes on the first minute of the hour. - Enhanced document create, delete, and update webhook handlers to determine and log the entity type. - Refactored document sync event handler to include entity type in sync operations and logging. - Added a new test script for uploading preview images to EspoCRM and verifying the upload process. - Created a test script for document thumbnail generation, including document creation, file upload, webhook triggering, and preview verification.
This commit is contained in:
@@ -151,17 +151,27 @@ async def handler(request: ApiRequest, ctx: FlowContext[Any]) -> ApiResponse:
|
||||
)
|
||||
|
||||
# Emit events für Queue-Processing (Deduplizierung erfolgt im Event-Handler via Lock)
|
||||
# Versuche Entity-Type zu ermitteln
|
||||
entity_type = 'CDokumente' # Default für VMH
|
||||
if isinstance(payload, list) and payload:
|
||||
entity_type = payload[0].get('entityType') or payload[0].get('_scope') or 'CDokumente'
|
||||
elif isinstance(payload, dict):
|
||||
entity_type = payload.get('entityType') or payload.get('_scope') or 'CDokumente'
|
||||
|
||||
ctx.logger.info(f"📝 Entity-Type: {entity_type}")
|
||||
|
||||
for entity_id in entity_ids:
|
||||
await ctx.enqueue({
|
||||
'topic': 'vmh.document.create',
|
||||
'data': {
|
||||
'entity_id': entity_id,
|
||||
'entity_type': entity_type,
|
||||
'action': 'create',
|
||||
'source': 'webhook',
|
||||
'timestamp': datetime.datetime.now().isoformat()
|
||||
}
|
||||
})
|
||||
ctx.logger.info(f"✅ Event emittiert: vmh.document.create für ID {entity_id}")
|
||||
ctx.logger.info(f"✅ Event emittiert: vmh.document.create für ID {entity_id} (Type: {entity_type})")
|
||||
|
||||
ctx.logger.info("\n" + "=" * 80)
|
||||
ctx.logger.info(f"✅ WEBHOOK VERARBEITUNG ABGESCHLOSSEN")
|
||||
|
||||
@@ -128,17 +128,27 @@ async def handler(request: ApiRequest, ctx: FlowContext[Any]) -> ApiResponse:
|
||||
)
|
||||
|
||||
# Emit events für Queue-Processing
|
||||
# Versuche Entity-Type zu ermitteln
|
||||
entity_type = 'CDokumente' # Default für VMH
|
||||
if isinstance(payload, list) and payload:
|
||||
entity_type = payload[0].get('entityType') or payload[0].get('_scope') or 'CDokumente'
|
||||
elif isinstance(payload, dict):
|
||||
entity_type = payload.get('entityType') or payload.get('_scope') or 'CDokumente'
|
||||
|
||||
ctx.logger.info(f"📝 Entity-Type: {entity_type}")
|
||||
|
||||
for entity_id in entity_ids:
|
||||
await ctx.enqueue({
|
||||
'topic': 'vmh.document.delete',
|
||||
'data': {
|
||||
'entity_id': entity_id,
|
||||
'entity_type': entity_type,
|
||||
'action': 'delete',
|
||||
'source': 'webhook',
|
||||
'timestamp': datetime.datetime.now().isoformat()
|
||||
}
|
||||
})
|
||||
ctx.logger.info(f"✅ Event emittiert: vmh.document.delete für ID {entity_id}")
|
||||
ctx.logger.info(f"✅ Event emittiert: vmh.document.delete für ID {entity_id} (Type: {entity_type})")
|
||||
|
||||
ctx.logger.info("\n" + "=" * 80)
|
||||
ctx.logger.info(f"✅ WEBHOOK VERARBEITUNG ABGESCHLOSSEN")
|
||||
|
||||
@@ -150,17 +150,27 @@ async def handler(request: ApiRequest, ctx: FlowContext[Any]) -> ApiResponse:
|
||||
)
|
||||
|
||||
# Emit events für Queue-Processing
|
||||
# Versuche Entity-Type zu ermitteln
|
||||
entity_type = 'CDokumente' # Default für VMH
|
||||
if isinstance(payload, list) and payload:
|
||||
entity_type = payload[0].get('entityType') or payload[0].get('_scope') or 'CDokumente'
|
||||
elif isinstance(payload, dict):
|
||||
entity_type = payload.get('entityType') or payload.get('_scope') or 'CDokumente'
|
||||
|
||||
ctx.logger.info(f"📝 Entity-Type: {entity_type}")
|
||||
|
||||
for entity_id in entity_ids:
|
||||
await ctx.enqueue({
|
||||
'topic': 'vmh.document.update',
|
||||
'data': {
|
||||
'entity_id': entity_id,
|
||||
'entity_type': entity_type,
|
||||
'action': 'update',
|
||||
'source': 'webhook',
|
||||
'timestamp': datetime.datetime.now().isoformat()
|
||||
}
|
||||
})
|
||||
ctx.logger.info(f"✅ Event emittiert: vmh.document.update für ID {entity_id}")
|
||||
ctx.logger.info(f"✅ Event emittiert: vmh.document.update für ID {entity_id} (Type: {entity_type})")
|
||||
|
||||
ctx.logger.info("\n" + "=" * 80)
|
||||
ctx.logger.info(f"✅ WEBHOOK VERARBEITUNG ABGESCHLOSSEN")
|
||||
|
||||
Reference in New Issue
Block a user