diff --git a/src/Socialbox/Classes/StandardMethods/GetMe.php b/src/Socialbox/Classes/StandardMethods/GetMe.php new file mode 100644 index 0000000..9621320 --- /dev/null +++ b/src/Socialbox/Classes/StandardMethods/GetMe.php @@ -0,0 +1,47 @@ +getSessionUuid() === null) + { + return $rpcRequest->produceError(StandardError::SESSION_REQUIRED); + } + + try + { + // Get the session and check if it's already authenticated + $session = SessionManager::getSession($request->getSessionUuid()); + if($session->getAuthenticatedPeerUuid() === null) + { + return $rpcRequest->produceError(StandardError::AUTHENTICATION_REQUIRED); + } + + // Get the peer and return it + return $rpcRequest->produceResponse(RegisteredPeerManager::getPeer($session->getAuthenticatedPeerUuid())->toSelfUser()); + } + catch(DatabaseOperationException $e) + { + throw new StandardException("There was an unexpected error while trying to register", StandardError::INTERNAL_SERVER_ERROR, $e); + } + } +} \ No newline at end of file