From 2b1e7369fde8b96f25286a0248396e50a688d5be Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 21 Feb 2024 11:38:57 +0200 Subject: [PATCH] add node settings username validation --- src/controller/room.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/controller/room.php b/src/controller/room.php index f6432d2..4b420ef 100644 --- a/src/controller/room.php +++ b/src/controller/room.php @@ -536,20 +536,22 @@ class Room return null; } + // Set timestamp + $time = isset($transaction['time']) ? $transaction['time'] : time(); + + // Set default username + $user = $this->_config->kevachat->user->name->guest; + // Detect username (key @postfix) if (preg_match('/@([^@]+)$/', $data['key'], $match)) { - $user = $match[1]; - } - - else - { - $user = $this->_config->kevachat->user->name->guest; + // Set username on match node settings + if (preg_match($this->_config->kevachat->user->name->regex, $match[1])) + { + $user = $match[1]; + } } - // Return timestamp - $time = isset($transaction['time']) ? $transaction['time'] : time(); - // Is raw field request if ($field) {