feat(audit): record user action events across gateway and channels
This commit is contained in:
@@ -350,6 +350,20 @@ export function createMessageRouter(deps: {
|
||||
const commandInput = msg.metadata?.isCommand && typeof msg.metadata.command === 'string'
|
||||
? `/${msg.metadata.command}${msg.metadata.commandArgs ? ` ${msg.metadata.commandArgs}` : ''}`
|
||||
: incomingText;
|
||||
const metadataCommand = typeof msg.metadata?.command === 'string' ? msg.metadata.command : undefined;
|
||||
const parsedCommand = msg.metadata?.isCommand
|
||||
? metadataCommand
|
||||
: commandInput.startsWith('/') ? commandInput.slice(1).split(/\s+/, 1)[0] : undefined;
|
||||
auditLogger?.userAction({
|
||||
session_id: `${msg.channel}:${msg.senderId}`,
|
||||
channel: msg.channel,
|
||||
sender: msg.senderId,
|
||||
source: 'channel',
|
||||
action_type: parsedCommand ? 'command' : 'message',
|
||||
content_length: commandInput.length,
|
||||
attachments_count: msg.attachments?.length ?? 0,
|
||||
command: parsedCommand,
|
||||
});
|
||||
|
||||
if (deps.commandRegistry && deps.commandRegistry.isCommand(commandInput)) {
|
||||
const session = deps.sessionManager.getSession(msg.channel, msg.senderId);
|
||||
|
||||
Reference in New Issue
Block a user