fix(hooks): 9 hook wiring fixes — DMS/Calendar name mismatch, Mail/Contact missing triggers
Check Cross-Plugin Imports / check (push) Has been cancelled

This commit is contained in:
Agent Zero
2026-08-17 07:21:39 +02:00
parent 0a1ba30ed7
commit 8de35a24a7
10 changed files with 1255 additions and 568 deletions
+3
View File
@@ -471,6 +471,7 @@ async def create_entry(
# ── Hook: calendar.after_appointment (Action) ──
from app.core.hooks import do_action
await do_action("calendar.after_appointment", entry_id=str(entry.id), tenant_id=tenant_id, user_id=user_id)
await do_action("calendar_entry.after_create", entry_id=str(entry.id), tenant_id=tenant_id, user_id=user_id)
# Schedule reminder ARQ job if reminder is set
if body.reminder:
@@ -665,6 +666,7 @@ async def update_entry(
snapshot_before=snapshot_before, snapshot_after=snapshot_after, changes=changes or None)
from app.core.hooks import do_action
await do_action("calendar.after_update", entry_id=str(entry.id), tenant_id=tenant_id, user_id=user_id)
await do_action("calendar_entry.after_update", entry_id=str(entry.id), tenant_id=tenant_id, user_id=user_id)
return snapshot_after
@@ -694,6 +696,7 @@ async def delete_entry(
await record_history(db, tenant_id, user_id, "calendar_entry", entry.id, "delete", snapshot_before=snapshot_before)
from app.core.hooks import do_action
await do_action("calendar.after_delete", tenant_id=tenant_id, user_id=user_id, entry_id=entry_id)
await do_action("calendar_entry.after_delete", tenant_id=tenant_id, user_id=user_id, entry_id=entry_id)
return Response(status_code=204)
+3
View File
@@ -623,6 +623,7 @@ async def upload_file(
# Lifecycle hook: dms.after_upload
from app.core.hooks import do_action
await do_action("dms.after_upload", {'id': str(dms_file.id), 'name': dms_file.name, 'folder_id': str(dms_file.folder_id) if dms_file.folder_id else None, 'mime_type': dms_file.mime_type, 'size_bytes': dms_file.size_bytes}, db=db, tenant_id=tenant_id, user_id=user_id)
await do_action("dms_file.after_create", {'id': str(dms_file.id), 'name': dms_file.name, 'tenant_id': str(tenant_id)}, db=db, tenant_id=tenant_id, user_id=user_id)
# Outbox event: file.created
from app.core.outbox import enqueue_outbox_event
@@ -846,6 +847,7 @@ async def update_file(
# Lifecycle hook: dms.after_update
from app.core.hooks import do_action
await do_action("dms.after_update", {'id': str(dms_file.id), 'name': dms_file.name}, db=db, tenant_id=tenant_id, user_id=user_id, file_id=file_id)
await do_action("dms_file.after_update", {'id': str(dms_file.id), 'name': dms_file.name, 'tenant_id': str(tenant_id)}, db=db, tenant_id=tenant_id, user_id=user_id, file_id=file_id)
return {
"id": str(dms_file.id),
@@ -908,6 +910,7 @@ async def delete_file(
# Lifecycle hook: dms.after_delete
await do_action("dms.after_delete", db=db, tenant_id=tenant_id, user_id=user_id, file_id=file_id)
await do_action("dms_file.after_delete", db=db, tenant_id=tenant_id, user_id=user_id, file_id=file_id)
# Outbox event: file.deleted
from app.core.outbox import enqueue_outbox_event
+2
View File
@@ -826,6 +826,7 @@ async def imap_sync_folder(
# Lifecycle hook: mail.after_receive
from app.core.hooks import do_action
await do_action("mail.after_receive", {'mail_id': str(mail.id), 'tenant_id': str(tenant_id), 'account_id': str(account.id), 'folder_id': str(folder.id), 'subject': subject, 'from_address': from_addr}, db=db, tenant_id=tenant_id)
await do_action("mail.after_create", {'mail_id': str(mail.id), 'tenant_id': str(tenant_id), 'subject': subject, 'from_address': from_addr}, db=db, tenant_id=tenant_id)
# Outbox event: mail.received
from app.core.outbox import enqueue_outbox_event
@@ -1584,6 +1585,7 @@ async def send_mail_via_smtp(
# ── Hook: mail.after_send (Action) ──
from app.core.hooks import do_action
await do_action("mail.after_send", mail_data, db=db, account=account, msg_id=msg_id)
await do_action("mail.after_update", mail_data, db=db, tenant_id=str(mail_data.get('tenant_id', '')) if isinstance(mail_data, dict) else None)
# Store sent mail in Sent folder — use configured mapping if set,
# otherwise flexible lookup to handle different IMAP naming conventions
+3
View File
@@ -464,6 +464,9 @@ async def delete_contact(
action="delete", snapshot_before=snapshot_before,
)
# Hook: contact.after_delete
await do_action("contact.after_delete", db=db, tenant_id=tenant_id, contact_id=contact_id, user_id=user_id)
async def hard_delete_contact(db: AsyncSession, tenant_id: uuid.UUID, contact_id: str) -> None:
"""GDPR hard-delete a contact."""