From a7fc8e87d9b44c5d302e9538d2fe5974a20b05eb Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 3 Feb 2025 15:22:44 -0500 Subject: [PATCH] Added method SettingsInformationFieldExists --- .../SettingsInformationFieldExists.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Socialbox/Classes/StandardMethods/Settings/SettingsInformationFieldExists.php diff --git a/src/Socialbox/Classes/StandardMethods/Settings/SettingsInformationFieldExists.php b/src/Socialbox/Classes/StandardMethods/Settings/SettingsInformationFieldExists.php new file mode 100644 index 0000000..3823e81 --- /dev/null +++ b/src/Socialbox/Classes/StandardMethods/Settings/SettingsInformationFieldExists.php @@ -0,0 +1,46 @@ +containsParameter('field')) + { + throw new MissingRpcArgumentException('field'); + } + $fieldName = InformationFieldName::tryFrom(strtoupper($rpcRequest->getParameter('field'))); + if($fieldName === null) + { + throw new InvalidRpcArgumentException('field'); + } + + try + { + return $rpcRequest->produceResponse(PeerInformationManager::fieldExists($request->getPeer(), $fieldName)); + + } + catch(DatabaseOperationException $e) + { + throw new StandardRpcException('Failed to check if the requested information field exists or not', StandardError::INTERNAL_SERVER_ERROR, $e); + } + } + } \ No newline at end of file