feat(webhooks): Add webhook handlers for Beteiligte and Document entities
- Implemented create, update, and delete webhook handlers for Beteiligte. - Implemented create, update, and delete webhook handlers for Document entities. - Added logging and error handling for each webhook handler. - Created a universal step for generating document previews. - Ensured payload validation and entity ID extraction for batch processing.
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
# Akte sync steps – unified sync across Advoware, EspoCRM, and xAI
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
# Akte webhook steps
|
|
||||||
0
src/steps/crm/__init__.py
Normal file
0
src/steps/crm/__init__.py
Normal file
0
src/steps/crm/akte/__init__.py
Normal file
0
src/steps/crm/akte/__init__.py
Normal file
@@ -356,16 +356,25 @@ async def _run_advoware_sync(
|
|||||||
ctx.logger.error(f" ❌ Error for hnr {hnr} ({filename}): {e}")
|
ctx.logger.error(f" ❌ Error for hnr {hnr} ({filename}): {e}")
|
||||||
results['errors'] += 1
|
results['errors'] += 1
|
||||||
|
|
||||||
# ── Ablage check ───────────────────────────────────────────────────
|
# ── Ablage check + Rubrum sync ─────────────────────────────────────
|
||||||
try:
|
try:
|
||||||
akte_details = await advoware_service.get_akte(aktennummer)
|
akte_details = await advoware_service.get_akte(aktennummer)
|
||||||
if akte_details and akte_details.get('ablage') == 1:
|
if akte_details:
|
||||||
ctx.logger.info("📁 Akte marked as ablage → deactivating")
|
espo_update: Dict[str, Any] = {}
|
||||||
await espocrm.update_entity('CAkten', akte_id, {
|
|
||||||
'aktivierungsstatus': 'deaktiviert',
|
if akte_details.get('ablage') == 1:
|
||||||
})
|
ctx.logger.info("📁 Akte marked as ablage → deactivating")
|
||||||
|
espo_update['aktivierungsstatus'] = 'deaktiviert'
|
||||||
|
|
||||||
|
rubrum = akte_details.get('rubrum')
|
||||||
|
if rubrum and rubrum != akte.get('rubrum'):
|
||||||
|
espo_update['rubrum'] = rubrum
|
||||||
|
ctx.logger.info(f"📝 Rubrum synced: {rubrum[:80]}")
|
||||||
|
|
||||||
|
if espo_update:
|
||||||
|
await espocrm.update_entity('CAkten', akte_id, espo_update)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ctx.logger.warn(f"⚠️ Ablage check failed: {e}")
|
ctx.logger.warn(f"⚠️ Ablage/Rubrum check failed: {e}")
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
0
src/steps/crm/akte/webhooks/__init__.py
Normal file
0
src/steps/crm/akte/webhooks/__init__.py
Normal file
@@ -19,7 +19,7 @@ config = {
|
|||||||
"name": "Akte Webhook - EspoCRM",
|
"name": "Akte Webhook - EspoCRM",
|
||||||
"description": "Empfängt EspoCRM-Webhooks für CAkten und queued Entity-IDs für den Sync",
|
"description": "Empfängt EspoCRM-Webhooks für CAkten und queued Entity-IDs für den Sync",
|
||||||
"flows": ["akte-sync"],
|
"flows": ["akte-sync"],
|
||||||
"triggers": [http("POST", "/akte/webhook/update")],
|
"triggers": [http("POST", "/crm/akte/webhook/update")],
|
||||||
"enqueues": [],
|
"enqueues": [],
|
||||||
}
|
}
|
||||||
|
|
||||||
0
src/steps/crm/bankverbindungen/__init__.py
Normal file
0
src/steps/crm/bankverbindungen/__init__.py
Normal file
0
src/steps/crm/bankverbindungen/webhooks/__init__.py
Normal file
0
src/steps/crm/bankverbindungen/webhooks/__init__.py
Normal file
@@ -10,7 +10,7 @@ config = {
|
|||||||
"description": "Receives create webhooks from EspoCRM for Bankverbindungen",
|
"description": "Receives create webhooks from EspoCRM for Bankverbindungen",
|
||||||
"flows": ["vmh-bankverbindungen"],
|
"flows": ["vmh-bankverbindungen"],
|
||||||
"triggers": [
|
"triggers": [
|
||||||
http("POST", "/vmh/webhook/bankverbindungen/create")
|
http("POST", "/crm/bankverbindungen/webhook/create")
|
||||||
],
|
],
|
||||||
"enqueues": ["vmh.bankverbindungen.create"],
|
"enqueues": ["vmh.bankverbindungen.create"],
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ config = {
|
|||||||
"description": "Receives delete webhooks from EspoCRM for Bankverbindungen",
|
"description": "Receives delete webhooks from EspoCRM for Bankverbindungen",
|
||||||
"flows": ["vmh-bankverbindungen"],
|
"flows": ["vmh-bankverbindungen"],
|
||||||
"triggers": [
|
"triggers": [
|
||||||
http("POST", "/vmh/webhook/bankverbindungen/delete")
|
http("POST", "/crm/bankverbindungen/webhook/delete")
|
||||||
],
|
],
|
||||||
"enqueues": ["vmh.bankverbindungen.delete"],
|
"enqueues": ["vmh.bankverbindungen.delete"],
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ config = {
|
|||||||
"description": "Receives update webhooks from EspoCRM for Bankverbindungen",
|
"description": "Receives update webhooks from EspoCRM for Bankverbindungen",
|
||||||
"flows": ["vmh-bankverbindungen"],
|
"flows": ["vmh-bankverbindungen"],
|
||||||
"triggers": [
|
"triggers": [
|
||||||
http("POST", "/vmh/webhook/bankverbindungen/update")
|
http("POST", "/crm/bankverbindungen/webhook/update")
|
||||||
],
|
],
|
||||||
"enqueues": ["vmh.bankverbindungen.update"],
|
"enqueues": ["vmh.bankverbindungen.update"],
|
||||||
}
|
}
|
||||||
0
src/steps/crm/beteiligte/__init__.py
Normal file
0
src/steps/crm/beteiligte/__init__.py
Normal file
0
src/steps/crm/beteiligte/webhooks/__init__.py
Normal file
0
src/steps/crm/beteiligte/webhooks/__init__.py
Normal file
@@ -10,7 +10,7 @@ config = {
|
|||||||
"description": "Receives create webhooks from EspoCRM for Beteiligte",
|
"description": "Receives create webhooks from EspoCRM for Beteiligte",
|
||||||
"flows": ["vmh-beteiligte"],
|
"flows": ["vmh-beteiligte"],
|
||||||
"triggers": [
|
"triggers": [
|
||||||
http("POST", "/vmh/webhook/beteiligte/create")
|
http("POST", "/crm/beteiligte/webhook/create")
|
||||||
],
|
],
|
||||||
"enqueues": ["vmh.beteiligte.create"],
|
"enqueues": ["vmh.beteiligte.create"],
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ config = {
|
|||||||
"description": "Receives delete webhooks from EspoCRM for Beteiligte",
|
"description": "Receives delete webhooks from EspoCRM for Beteiligte",
|
||||||
"flows": ["vmh-beteiligte"],
|
"flows": ["vmh-beteiligte"],
|
||||||
"triggers": [
|
"triggers": [
|
||||||
http("POST", "/vmh/webhook/beteiligte/delete")
|
http("POST", "/crm/beteiligte/webhook/delete")
|
||||||
],
|
],
|
||||||
"enqueues": ["vmh.beteiligte.delete"],
|
"enqueues": ["vmh.beteiligte.delete"],
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ config = {
|
|||||||
"description": "Receives update webhooks from EspoCRM for Beteiligte",
|
"description": "Receives update webhooks from EspoCRM for Beteiligte",
|
||||||
"flows": ["vmh-beteiligte"],
|
"flows": ["vmh-beteiligte"],
|
||||||
"triggers": [
|
"triggers": [
|
||||||
http("POST", "/vmh/webhook/beteiligte/update")
|
http("POST", "/crm/beteiligte/webhook/update")
|
||||||
],
|
],
|
||||||
"enqueues": ["vmh.beteiligte.update"],
|
"enqueues": ["vmh.beteiligte.update"],
|
||||||
}
|
}
|
||||||
0
src/steps/crm/document/__init__.py
Normal file
0
src/steps/crm/document/__init__.py
Normal file
0
src/steps/crm/document/webhooks/__init__.py
Normal file
0
src/steps/crm/document/webhooks/__init__.py
Normal file
@@ -8,7 +8,7 @@ config = {
|
|||||||
"description": "Receives update webhooks from EspoCRM for CAIKnowledge entities",
|
"description": "Receives update webhooks from EspoCRM for CAIKnowledge entities",
|
||||||
"flows": ["vmh-aiknowledge"],
|
"flows": ["vmh-aiknowledge"],
|
||||||
"triggers": [
|
"triggers": [
|
||||||
http("POST", "/vmh/webhook/aiknowledge/update")
|
http("POST", "/crm/document/webhook/aiknowledge/update")
|
||||||
],
|
],
|
||||||
"enqueues": ["aiknowledge.sync"],
|
"enqueues": ["aiknowledge.sync"],
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ config = {
|
|||||||
"description": "Empfängt Create-Webhooks von EspoCRM für Documents",
|
"description": "Empfängt Create-Webhooks von EspoCRM für Documents",
|
||||||
"flows": ["vmh-documents"],
|
"flows": ["vmh-documents"],
|
||||||
"triggers": [
|
"triggers": [
|
||||||
http("POST", "/vmh/webhook/document/create")
|
http("POST", "/crm/document/webhook/create")
|
||||||
],
|
],
|
||||||
"enqueues": ["vmh.document.create"],
|
"enqueues": ["vmh.document.create"],
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ config = {
|
|||||||
"description": "Empfängt Delete-Webhooks von EspoCRM für Documents",
|
"description": "Empfängt Delete-Webhooks von EspoCRM für Documents",
|
||||||
"flows": ["vmh-documents"],
|
"flows": ["vmh-documents"],
|
||||||
"triggers": [
|
"triggers": [
|
||||||
http("POST", "/vmh/webhook/document/delete")
|
http("POST", "/crm/document/webhook/delete")
|
||||||
],
|
],
|
||||||
"enqueues": ["vmh.document.delete"],
|
"enqueues": ["vmh.document.delete"],
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ config = {
|
|||||||
"description": "Empfängt Update-Webhooks von EspoCRM für Documents",
|
"description": "Empfängt Update-Webhooks von EspoCRM für Documents",
|
||||||
"flows": ["vmh-documents"],
|
"flows": ["vmh-documents"],
|
||||||
"triggers": [
|
"triggers": [
|
||||||
http("POST", "/vmh/webhook/document/update")
|
http("POST", "/crm/document/webhook/update")
|
||||||
],
|
],
|
||||||
"enqueues": ["vmh.document.update"],
|
"enqueues": ["vmh.document.update"],
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
# Shared steps used across multiple modules
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
"""VMH Steps"""
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
"""VMH Webhook Steps"""
|
|
||||||
Reference in New Issue
Block a user