feat(B-HOOK): Lifecycle Hooks + Outbox Events — 55 neue Hooks, 10 Domain Events
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
B-HOOK-CORE: Company Hooks (6: before/after create/update/delete) B-HOOK-MAIL: Mail Hooks (5: after_receive, before/after_delete, before/after_move) B-HOOK-DMS: DMS Hooks (10: after_upload, before/after_update/delete/restore, folder CRUD) B-HOOK-CAL: Calendar Hooks (4: before/after update/delete) B-HOOK-TASK: Task Hooks (6: before/after create/update/delete) B-HOOK-COMM: Communication Hooks (8: conversation create, message/edit/delete) B-HOOK-AI: Agent Hooks (2: before/after_run) B-HOOK-WF: Workflow Hooks (4: before/after_start, after_complete/cancel) B-HOOK-TAG: Tag Hooks (8: create/assign/unassign/delete) B-HOOK-SEARCH: Search Filters (2: before/after_search) B-EVT-OUTBOX: 10 Domain Events (task.completed, file.created/deleted/restored, mail.received, workflow.started/completed/cancelled, agent.run_started/completed) B-HOOK-TEST: 79 Tests in test_lifecycle_hooks.py — alle grün B-HOOK-DOC: Plugin-Dev-Guide Kapitel 8 aktualisiert (Hook-Liste + Outbox Event-Liste)
This commit is contained in:
@@ -101,6 +101,8 @@ async def create_company(
|
||||
for k, v in body.items():
|
||||
if k not in ("name", "industry", "description"):
|
||||
custom[k] = v
|
||||
from app.core.hooks import do_action
|
||||
await do_action("company.before_create", body, db=db, tenant_id=tenant_id, user_id=user_id)
|
||||
company = Contact(
|
||||
tenant_id=tenant_id, type="company", name=name, displayname=name,
|
||||
status=body.get("status", "lead"), custom=custom,
|
||||
@@ -115,6 +117,8 @@ async def create_company(
|
||||
)
|
||||
db.add(audit_entry)
|
||||
await db.flush()
|
||||
from app.core.hooks import do_action
|
||||
await do_action("company.after_create", _serialize_company(company), db=db, tenant_id=tenant_id, user_id=user_id)
|
||||
return _serialize_company(company)
|
||||
|
||||
|
||||
@@ -202,6 +206,8 @@ async def update_company(
|
||||
company = result.scalar_one_or_none()
|
||||
if not company:
|
||||
raise HTTPException(status_code=404, detail="Company not found")
|
||||
from app.core.hooks import do_action
|
||||
await do_action("company.before_update", body, db=db, tenant_id=tenant_id, user_id=user_id, company_id=company_id)
|
||||
if "name" in body:
|
||||
company.name = body["name"]
|
||||
company.displayname = body["name"]
|
||||
@@ -220,6 +226,8 @@ async def update_company(
|
||||
entity_type="contact", entity_id=company.id, changes=body)
|
||||
db.add(audit_entry)
|
||||
await db.flush()
|
||||
from app.core.hooks import do_action
|
||||
await do_action("company.after_update", _serialize_company(company), db=db, tenant_id=tenant_id, user_id=user_id, company_id=company_id)
|
||||
return _serialize_company(company)
|
||||
|
||||
|
||||
@@ -241,6 +249,8 @@ async def delete_company(
|
||||
if not company:
|
||||
raise HTTPException(status_code=404, detail="Company not found")
|
||||
snapshot = _serialize_company(company)
|
||||
from app.core.hooks import do_action
|
||||
await do_action("company.before_delete", db=db, tenant_id=tenant_id, user_id=user_id, company_id=company_id)
|
||||
# Soft-delete contact persons via SQL to avoid lazy loading
|
||||
company.deleted_at = datetime.now(UTC)
|
||||
company.updated_by = user_id
|
||||
@@ -253,6 +263,8 @@ async def delete_company(
|
||||
entity_type="contact", entity_id=company.id, changes={"name": company.name})
|
||||
db.add(audit_entry)
|
||||
await db.flush()
|
||||
from app.core.hooks import do_action
|
||||
await do_action("company.after_delete", snapshot, db=db, tenant_id=tenant_id, user_id=user_id, company_id=company_id)
|
||||
return Response(status_code=status.HTTP_204_NO_CONTENT)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user