From 426df314214efd1fbe5b73703e736fa9e9e3a228 Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 6 Jan 2025 04:44:35 -0500 Subject: [PATCH] Update display name logic and handle invalid arguments. --- .../StandardMethods/SettingsSetDisplayName.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Socialbox/Classes/StandardMethods/SettingsSetDisplayName.php b/src/Socialbox/Classes/StandardMethods/SettingsSetDisplayName.php index 93b8d90..148e0f8 100644 --- a/src/Socialbox/Classes/StandardMethods/SettingsSetDisplayName.php +++ b/src/Socialbox/Classes/StandardMethods/SettingsSetDisplayName.php @@ -3,6 +3,7 @@ namespace Socialbox\Classes\StandardMethods; use Exception; + use ncc\ThirdParty\Symfony\Process\Exception\InvalidArgumentException; use Socialbox\Abstracts\Method; use Socialbox\Enums\Flags\SessionFlags; use Socialbox\Enums\StandardError; @@ -27,14 +28,15 @@ try { - // Set the password + // Update the display name RegisteredPeerManager::updateDisplayName($request->getPeer(), $rpcRequest->getParameter('name')); - // Remove the SET_PASSWORD flag - SessionManager::removeFlags($request->getSessionUuid(), [SessionFlags::SET_DISPLAY_NAME]); - // Check & update the session flow - SessionManager::updateFlow($request->getSession()); + SessionManager::updateFlow($request->getSession(), [SessionFlags::SET_DISPLAY_NAME]); + } + catch(InvalidArgumentException) + { + return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'Invalid display name'); } catch(Exception $e) {