diff --git a/src/Socialbox/Classes/StandardMethods/SettingsGetInformationField.php b/src/Socialbox/Classes/StandardMethods/SettingsGetInformationField.php new file mode 100644 index 0000000..640e12e --- /dev/null +++ b/src/Socialbox/Classes/StandardMethods/SettingsGetInformationField.php @@ -0,0 +1,48 @@ +containsParameter('field')) + { + return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'The required field parameter is missing'); + } + $fieldName = InformationFieldName::tryFrom(strtoupper($rpcRequest->getParameter('field'))); + if($fieldName === null) + { + return $rpcRequest->produceError(StandardError::RPC_INVALID_ARGUMENTS, 'The provided field parameter is invalid'); + } + + try + { + $fieldRecord = PeerInformationManager::getField($request->getPeer(), $fieldName); + } + catch(DatabaseOperationException $e) + { + throw new StandardException('Failed to retrieve existing information fields', StandardError::INTERNAL_SERVER_ERROR, $e); + } + + if($fieldRecord === null) + { + return $rpcRequest->produceError(StandardError::NOT_FOUND, 'The requested field does not exist'); + } + + return $rpcRequest->produceResponse($fieldRecord->toInformationFieldState()); + } + } \ No newline at end of file