Increase security and reformat
This commit is contained in:
@@ -8,7 +8,6 @@ from asgiref.sync import sync_to_async
|
||||
from core.models import GatewayCommandEvent
|
||||
from core.security.command_policy import CommandSecurityContext, evaluate_command_policy
|
||||
|
||||
|
||||
GatewayEmit = Callable[[str], None]
|
||||
GatewayHandler = Callable[["GatewayCommandContext", GatewayEmit], Awaitable[bool]]
|
||||
GatewayMatcher = Callable[[str], bool]
|
||||
@@ -103,7 +102,10 @@ async def dispatch_gateway_command(
|
||||
emit(message)
|
||||
event.status = "blocked"
|
||||
event.error = f"{decision.code}:{decision.reason}"
|
||||
event.response_meta = {"policy_code": decision.code, "policy_reason": decision.reason}
|
||||
event.response_meta = {
|
||||
"policy_code": decision.code,
|
||||
"policy_reason": decision.reason,
|
||||
}
|
||||
await sync_to_async(event.save)(
|
||||
update_fields=["status", "error", "response_meta", "updated_at"]
|
||||
)
|
||||
@@ -129,5 +131,7 @@ async def dispatch_gateway_command(
|
||||
|
||||
event.status = "ok" if handled else "ignored"
|
||||
event.response_meta = {"responses": responses}
|
||||
await sync_to_async(event.save)(update_fields=["status", "response_meta", "updated_at"])
|
||||
await sync_to_async(event.save)(
|
||||
update_fields=["status", "response_meta", "updated_at"]
|
||||
)
|
||||
return bool(handled)
|
||||
|
||||
Reference in New Issue
Block a user