Merge pull request #46273 from nextcloud/fix/make-ooo-replacement-nullable

Fix: Make out of office replacement nullable
This commit is contained in:
Hamza 2024-07-03 15:03:24 +02:00 committed by GitHub
commit 993424fc95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 27 additions and 25 deletions

View file

@ -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);

View file

@ -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');

View file

@ -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{

View file

@ -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);

View file

@ -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"
}
}

View file

@ -19,8 +19,8 @@ class OutOfOfficeData implements IOutOfOfficeData {
private int $endDate,
private string $shortMessage,
private string $message,
private string $replacementUserId,
private string $replacementUserDisplayName) {
private ?string $replacementUserId,
private ?string $replacementUserDisplayName) {
}
public function getId(): string {
@ -47,11 +47,11 @@ class OutOfOfficeData implements IOutOfOfficeData {
return $this->message;
}
public function getReplacementUserId(): string {
public function getReplacementUserId(): ?string {
return $this->replacementUserId;
}
public function getReplacementUserDisplayName(): string {
public function getReplacementUserDisplayName(): ?string {
return $this->replacementUserDisplayName;
}

View file

@ -22,8 +22,8 @@ use OCP\IUser;
* endDate: int,
* shortMessage: string,
* message: string,
* replacementUserId: string,
* replacementUserDisplayName: string
* replacementUserId: ?string,
* replacementUserDisplayName: ?string
* }
*
* @since 28.0.0
@ -76,14 +76,14 @@ interface IOutOfOfficeData extends JsonSerializable {
*
* @since 30.0.0
*/
public function getReplacementUserId(): string;
public function getReplacementUserId(): ?string;
/**
* Get the replacement user displayName for auto responders and similar
*
* @since 30.0.0
*/
public function getReplacementUserDisplayName(): string;
public function getReplacementUserDisplayName(): ?string;
/**
* @return OutOfOfficeData