17 lines
494 B
Python
17 lines
494 B
Python
import asyncio
|
|
from typing import Awaitable, Callable
|
|
|
|
from .. import audit
|
|
from ..db import Database
|
|
from .context import AuditEvent
|
|
|
|
ACTION_PREFIX = "command."
|
|
|
|
|
|
def command_audit(db: Database) -> Callable[[AuditEvent], Awaitable[None]]:
|
|
async def write(event: AuditEvent) -> None:
|
|
await asyncio.to_thread(audit.record, db, f"{event.backend}:{event.sender_id}",
|
|
f"{ACTION_PREFIX}{event.outcome}", event.command, None, event.args)
|
|
|
|
return write
|