mirror of
https://github.com/nextcloud/server.git
synced 2026-06-13 18:50:47 -04:00
Merge pull request #46273 from nextcloud/fix/make-ooo-replacement-nullable
Fix: Make out of office replacement nullable
This commit is contained in:
commit
993424fc95
7 changed files with 27 additions and 25 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue