fix(Text2Image): Fix $completionExpectedAt default value

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
Marcel Klehr 2023-10-22 12:20:29 +02:00
parent 9787f9dba0
commit 4055a90004
2 changed files with 10 additions and 8 deletions

View File

@ -153,7 +153,7 @@ namespace OCA\Core;
* input: string,
* identifier: ?string,
* numberOfImages: int,
* completionExpectedAt: int,
* completionExpectedAt: ?int,
* }
*/
class ResponseDefinitions {

View File

@ -40,7 +40,7 @@ use OCP\Image;
final class Task implements \JsonSerializable {
protected ?int $id = null;
protected DateTime $completionExpectedAt;
protected ?DateTime $completionExpectedAt = null;
/**
* @since 28.0.0
@ -95,7 +95,9 @@ final class Task implements \JsonSerializable {
$folder = $appData->getFolder('text2image')->getFolder((string)$this->getId());
$images = [];
for ($i = 0; $i < $this->getNumberOfImages(); $i++) {
$images[] = new Image(base64_encode($folder->getFile((string) $i)->getContent()));
$image = new Image();
$image->loadFromFileHandle($folder->getFile((string) $i)->read());
$images[] = $image;
}
return $images;
} catch (NotFoundException|NotPermittedException) {
@ -128,18 +130,18 @@ final class Task implements \JsonSerializable {
}
/**
* @param DateTime $at
* @param ?DateTime $at
* @since 28.0.0
*/
final public function setCompletionExpectedAt(DateTime $at): void {
final public function setCompletionExpectedAt(?DateTime $at): void {
$this->completionExpectedAt = $at;
}
/**
* @return DateTime
* @return ?DateTime
* @since 28.0.0
*/
final public function getCompletionExpectedAt(): DateTime {
final public function getCompletionExpectedAt(): ?DateTime {
return $this->completionExpectedAt;
}
@ -192,7 +194,7 @@ final class Task implements \JsonSerializable {
}
/**
* @psalm-return array{id: ?int, status: 0|1|2|3|4, userId: ?string, appId: string, input: string, identifier: ?string, numberOfImages: int, completionExpectedAt: int}
* @psalm-return array{id: ?int, status: 0|1|2|3|4, userId: ?string, appId: string, input: string, identifier: ?string, numberOfImages: int, completionExpectedAt: ?int}
* @since 28.0.0
*/
public function jsonSerialize(): array {