diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index 975e7aa769cf80631fc1f3fa60f7e5f0d6988968..eedb6e77227fa35e91067996fcbb4209b7b15937 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -67,35 +67,63 @@ class UserController extends ApiController { */ public function setAccountData(string $token, string $uid, string $email, string $recoveryEmail, string $hmeAlias, string $quota = '1024 MB', bool $tosAccepted = false): DataResponse { $response = new DataResponse(); - if (!$this->checkAppCredentials($token)) { $response->setStatus(401); return $response; } + $startTimestamp = time(); if (!$this->userService->userExists($uid)) { $response->setStatus(404); return $response; } - + $existsTimestamp = time(); + $existsTime = $existsTimestamp - $startTimestamp; + $user = $this->userService->getUser($uid); - if (is_null($user)) { $response->setStatus(404); return $response; } + $getUserTimestamp = time(); + $getUserTime = $getUserTimestamp - $existsTimestamp; $user->setEMailAddress($email); + $setEmailTimestamp = time(); + $setEmailTime = $setEmailTimestamp - $getUserTimestamp; + $user->setQuota($quota); + $setQuotaTimestamp = time(); + $setQuotaTime = $setQuotaTimestamp - $setEmailTimestamp; + $this->config->setUserValue($uid, 'terms_of_service', 'tosAccepted', intval($tosAccepted)); + $setTosTimestamp = time(); + $setTosTime = $setTosTimestamp - $setQuotaTimestamp; + $recoveryEmailUpdated = $this->userService->setRecoveryEmail($uid, $recoveryEmail); if (!$recoveryEmailUpdated) { return $this->getErrorResponse($response, 'error_setting_recovery', 400); } + $setRecoveryTimestamp = time(); + $setRecoveryTime = $setRecoveryTimestamp - $setTosTimestamp; + $hmeAliasAdded = $this->userService->addHMEAliasInConfig($uid, $hmeAlias); if (!$hmeAliasAdded) { return $this->getErrorResponse($response, 'error_adding_hme_alias', 400); } + $setHmeTimestamp = time(); + $setHmeTime = $setHmeTimestamp - $setRecoveryTimestamp; + $this->logger->error( + 'setAccountData-benchmark: starting at: ' . $startTimestamp . "\n" + . ' userExists time: ' . $existsTime . "\n" + . ' getUser time: ' . $getUserTime . "\n" + . ' setQuota time: ' . $setQuotaTime . "\n" + . ' setEmail time: ' . $setEmailTime . "\n" + . ' setTos time: ' . $setTosTime . "\n" + . ' setRecovery time: ' . $setRecoveryTime . "\n" + . ' setHme time: ' . $setHmeTime . "\n" + ); + return $response; }