aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorHamza Mahjoubi <hamzamahjoubi221@gmail.com>2024-07-03 10:47:59 +0200
committerHamza Mahjoubi <hamzamahjoubi221@gmail.com>2024-07-03 12:31:53 +0200
commit85a3b27cf956ebdb61f569ac04b7feb2d4835b37 (patch)
treea6f7fdd821cb601ef4f322ee90b9e46d6be04ec8 /apps
parent84699048b5626373d9e3e859bc48d9b355018fb9 (diff)
downloadnextcloud-server-85a3b27cf956ebdb61f569ac04b7feb2d4835b37.tar.gz
nextcloud-server-85a3b27cf956ebdb61f569ac04b7feb2d4835b37.zip
Fix: Make out of office replacement nullable
Signed-off-by: Hamza Mahjoubi <hamzamahjoubi221@gmail.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/Controller/OutOfOfficeController.php10
-rw-r--r--apps/dav/lib/Db/Absence.php8
-rw-r--r--apps/dav/lib/ResponseDefinitions.php4
-rw-r--r--apps/dav/lib/Service/AbsenceService.php4
-rw-r--r--apps/dav/openapi.json10
5 files changed, 19 insertions, 17 deletions
diff --git a/apps/dav/lib/Controller/OutOfOfficeController.php b/apps/dav/lib/Controller/OutOfOfficeController.php
index b77b77f4b5e..4978fb87737 100644
--- a/apps/dav/lib/Controller/OutOfOfficeController.php
+++ b/apps/dav/lib/Controller/OutOfOfficeController.php
@@ -105,8 +105,8 @@ 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
- * @param string $replacementUserId User id of the replacement user
- * @param string $replacementUserDisplayName Display name of the replacement user
+ * @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
@@ -120,8 +120,8 @@ class OutOfOfficeController extends OCSController {
string $lastDay,
string $status,
string $message,
- string $replacementUserId = '',
- string $replacementUserDisplayName = ''
+ ?string $replacementUserId,
+ ?string $replacementUserDisplayName
): DataResponse {
$user = $this->userSession?->getUser();
@@ -129,7 +129,7 @@ class OutOfOfficeController extends OCSController {
return new DataResponse(null, Http::STATUS_UNAUTHORIZED);
}
- if ($replacementUserId !== '') {
+ if ($replacementUserId !== null) {
$replacementUser = $this->userManager->get($replacementUserId);
if ($replacementUser === null) {
return new DataResponse(null, Http::STATUS_NOT_FOUND);
diff --git a/apps/dav/lib/Db/Absence.php b/apps/dav/lib/Db/Absence.php
index c58593e3e3f..550958aaabd 100644
--- a/apps/dav/lib/Db/Absence.php
+++ b/apps/dav/lib/Db/Absence.php
@@ -30,9 +30,9 @@ use OCP\User\IOutOfOfficeData;
* @method string getMessage()
* @method void setMessage(string $message)
* @method string getReplacementUserId()
- * @method void setReplacementUserId(string $replacementUserId)
+ * @method void setReplacementUserId(?string $replacementUserId)
* @method string getReplacementUserDisplayName()
- * @method void setReplacementUserDisplayName(string $replacementUserDisplayName)
+ * @method void setReplacementUserDisplayName(?string $replacementUserDisplayName)
*/
class Absence extends Entity implements JsonSerializable {
protected string $userId = '';
@@ -47,9 +47,9 @@ class Absence extends Entity implements JsonSerializable {
protected string $message = '';
- protected string $replacementUserId = '';
+ protected ?string $replacementUserId = null;
- protected string $replacementUserDisplayName = '';
+ protected ?string $replacementUserDisplayName = null;
public function __construct() {
$this->addType('userId', 'string');
diff --git a/apps/dav/lib/ResponseDefinitions.php b/apps/dav/lib/ResponseDefinitions.php
index 467c9a7b8bb..2dc0d4e8dbd 100644
--- a/apps/dav/lib/ResponseDefinitions.php
+++ b/apps/dav/lib/ResponseDefinitions.php
@@ -13,8 +13,8 @@ namespace OCA\DAV;
* @psalm-type DAVOutOfOfficeDataCommon = array{
* userId: string,
* message: string,
- * replacementUserId: string,
- * replacementUserDisplayName: string,
+ * replacementUserId: ?string,
+ * replacementUserDisplayName: ?string,
* }
*
* @psalm-type DAVOutOfOfficeData = DAVOutOfOfficeDataCommon&array{
diff --git a/apps/dav/lib/Service/AbsenceService.php b/apps/dav/lib/Service/AbsenceService.php
index 91e0b538c43..7cbc0386d43 100644
--- a/apps/dav/lib/Service/AbsenceService.php
+++ b/apps/dav/lib/Service/AbsenceService.php
@@ -61,8 +61,8 @@ class AbsenceService {
$absence->setLastDay($lastDay);
$absence->setStatus($status);
$absence->setMessage($message);
- $absence->setReplacementUserId($replacementUserId ?? '');
- $absence->setReplacementUserDisplayName($replacementUserDisplayName ?? '');
+ $absence->setReplacementUserId($replacementUserId);
+ $absence->setReplacementUserDisplayName($replacementUserDisplayName);
if ($absence->getId() === null) {
$absence = $this->absenceMapper->insert($absence);
diff --git a/apps/dav/openapi.json b/apps/dav/openapi.json
index d565035b8ac..946a603f44d 100644
--- a/apps/dav/openapi.json
+++ b/apps/dav/openapi.json
@@ -145,10 +145,12 @@
"type": "string"
},
"replacementUserId": {
- "type": "string"
+ "type": "string",
+ "nullable": true
},
"replacementUserDisplayName": {
- "type": "string"
+ "type": "string",
+ "nullable": true
}
}
}
@@ -578,12 +580,12 @@
},
"replacementUserId": {
"type": "string",
- "default": "",
+ "nullable": true,
"description": "User id of the replacement user"
},
"replacementUserDisplayName": {
"type": "string",
- "default": "",
+ "nullable": true,
"description": "Display name of the replacement user"
}
}