fix: Event-bus workflow trigger, RBAC on all routes, search provider, events, cron jobs
Critical fixes:
- Event Bus → Workflow auto-trigger: wildcard subscription starts workflows on matching events
- Kommunikation routes: require_permission on all 30+ endpoints (comm:read/write/delete/manage)
- Permissions routes: require_permission('permissions:admin') on all management endpoints
- CompanySearchProvider registered in auto_register_providers()
Medium fixes:
- system_notif events: 10 event_bus.publish() calls added (lead.created, contact.created/updated,
task.created/overdue, mail.received, user.created, workflow.completed, notification.created, backup.*)
- Cron jobs: backup_check (daily), search_index_check (daily), workflow_timeout (5min) registered
- AI tool permission: call_crm_api now requires 'ai:write' permission
- New file: automation/jobs.py with backup_check and search_index_check functions
This commit is contained in:
@@ -28,7 +28,10 @@ class EventBus:
|
||||
async def publish(self, event_name: str, payload: dict[str, Any]) -> None:
|
||||
"""Publish an event to all subscribers."""
|
||||
handlers = self._handlers.get(event_name, [])
|
||||
tasks = [asyncio.create_task(h(payload)) for h in handlers]
|
||||
# Also notify wildcard subscribers (catch-all '*' handlers)
|
||||
wildcard_handlers = self._handlers.get('*', [])
|
||||
all_handlers = handlers + wildcard_handlers
|
||||
tasks = [asyncio.create_task(h(payload)) for h in all_handlers]
|
||||
if tasks:
|
||||
await asyncio.gather(*tasks, return_exceptions=True)
|
||||
|
||||
|
||||
@@ -63,6 +63,18 @@ async def create_notification(
|
||||
)
|
||||
db.add(notif)
|
||||
await db.flush()
|
||||
|
||||
# Publish notification.created event
|
||||
from app.core.event_bus import get_event_bus
|
||||
event_bus = get_event_bus()
|
||||
await event_bus.publish('notification.created', {
|
||||
'notification_id': str(notif.id),
|
||||
'tenant_id': str(tenant_id),
|
||||
'user_id': str(user_id),
|
||||
'type': type,
|
||||
'title': title,
|
||||
})
|
||||
|
||||
return notif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user