diff options
author | Hamza Mahjoubi <hamzamahjoubi221@gmail.com> | 2024-06-10 16:30:53 +0200 |
---|---|---|
committer | Hamza Mahjoubi <hamzamahjoubi221@gmail.com> | 2024-07-01 15:10:16 +0200 |
commit | a9774741e815c02a9f5973bf6477a7c9da653732 (patch) | |
tree | 171ab358957d002bd4e13dea0d532d0c826ca51c /apps/dav/lib/Controller | |
parent | 3b75c5b98cd0356e99c07d9696c49732f195b3f6 (diff) | |
download | nextcloud-server-a9774741e815c02a9f5973bf6477a7c9da653732.tar.gz nextcloud-server-a9774741e815c02a9f5973bf6477a7c9da653732.zip |
Feat: Allow users to select another user as their out-of-office replacement
Signed-off-by: Hamza Mahjoubi <hamzamahjoubi221@gmail.com>
Diffstat (limited to 'apps/dav/lib/Controller')
-rw-r--r-- | apps/dav/lib/Controller/OutOfOfficeController.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/apps/dav/lib/Controller/OutOfOfficeController.php b/apps/dav/lib/Controller/OutOfOfficeController.php index b127c5c3cd3..b77b77f4b5e 100644 --- a/apps/dav/lib/Controller/OutOfOfficeController.php +++ b/apps/dav/lib/Controller/OutOfOfficeController.php @@ -93,6 +93,8 @@ class OutOfOfficeController extends OCSController { 'lastDay' => $data->getLastDay(), 'status' => $data->getStatus(), 'message' => $data->getMessage(), + 'replacementUserId' => $data->getReplacementUserId(), + 'replacementUserDisplayName' => $data->getReplacementUserDisplayName(), ]); } @@ -103,11 +105,14 @@ class OutOfOfficeController extends OCSController { * @param string $lastDay Last day of the absence in format `YYYY-MM-DD` * @param string $status Short text that is set as user status during the absence * @param string $message Longer multiline message that is shown to others during the absence - * @return DataResponse<Http::STATUS_OK, DAVOutOfOfficeData, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'firstDay'}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, null, array{}> + * @param string $replacementUserId User id of the replacement user + * @param string $replacementUserDisplayName Display name of the replacement user + * @return DataResponse<Http::STATUS_OK, DAVOutOfOfficeData, array{}>|DataResponse<Http::STATUS_BAD_REQUEST, array{error: 'firstDay'}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, null, array{}>|DataResponse<Http::STATUS_NOT_FOUND, null, array{}> * * 200: Absence data * 400: When the first day is not before the last day * 401: When the user is not logged in + * 404: When the replacementUserId was provided but replacement user was not found */ #[NoAdminRequired] public function setOutOfOffice( @@ -115,12 +120,22 @@ class OutOfOfficeController extends OCSController { string $lastDay, string $status, string $message, + string $replacementUserId = '', + string $replacementUserDisplayName = '' + ): DataResponse { $user = $this->userSession?->getUser(); if ($user === null) { return new DataResponse(null, Http::STATUS_UNAUTHORIZED); } + if ($replacementUserId !== '') { + $replacementUser = $this->userManager->get($replacementUserId); + if ($replacementUser === null) { + return new DataResponse(null, Http::STATUS_NOT_FOUND); + } + } + $parsedFirstDay = new DateTimeImmutable($firstDay); $parsedLastDay = new DateTimeImmutable($lastDay); if ($parsedFirstDay->getTimestamp() > $parsedLastDay->getTimestamp()) { @@ -133,6 +148,8 @@ class OutOfOfficeController extends OCSController { $lastDay, $status, $message, + $replacementUserId, + $replacementUserDisplayName ); $this->coordinator->clearCache($user->getUID()); @@ -143,6 +160,8 @@ class OutOfOfficeController extends OCSController { 'lastDay' => $data->getLastDay(), 'status' => $data->getStatus(), 'message' => $data->getMessage(), + 'replacementUserId' => $data->getReplacementUserId(), + 'replacementUserDisplayName' => $data->getReplacementUserDisplayName(), ]); } |