aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/TextProcessing/Task.php
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-02-23 15:47:17 +0100
committerGitHub <noreply@github.com>2024-02-23 15:47:17 +0100
commitb5357f7d12f89ce965cf8b8dd3bbc9cd0ad042c6 (patch)
treefb5982f6df0546adacb28cb67f96148dcfe78b33 /lib/public/TextProcessing/Task.php
parentce74bdcda244172cbe90dc792e30128802a78828 (diff)
parenta88c1bdfb61d4c141d90e6864971f6d456417604 (diff)
downloadnextcloud-server-b5357f7d12f89ce965cf8b8dd3bbc9cd0ad042c6.tar.gz
nextcloud-server-b5357f7d12f89ce965cf8b8dd3bbc9cd0ad042c6.zip
Merge branch 'master' into refactor/OC-Server-getThemingDefaults
Signed-off-by: John Molakvoæ <skjnldsv@users.noreply.github.com>
Diffstat (limited to 'lib/public/TextProcessing/Task.php')
-rw-r--r--lib/public/TextProcessing/Task.php36
1 files changed, 28 insertions, 8 deletions
diff --git a/lib/public/TextProcessing/Task.php b/lib/public/TextProcessing/Task.php
index 446e414cb04..c62b7b2fff8 100644
--- a/lib/public/TextProcessing/Task.php
+++ b/lib/public/TextProcessing/Task.php
@@ -28,13 +28,12 @@ namespace OCP\TextProcessing;
/**
* This is a text processing task
* @since 27.1.0
- * @psalm-template T of ITaskType
- * @psalm-template S as class-string<T>
- * @psalm-template P as IProvider<T>
+ * @psalm-template-covariant T of ITaskType
*/
final class Task implements \JsonSerializable {
protected ?int $id = null;
protected ?string $output = null;
+ private ?\DateTime $completionExpectedAt = null;
/**
* @since 27.1.0
@@ -73,7 +72,7 @@ final class Task implements \JsonSerializable {
protected int $status = self::STATUS_UNKNOWN;
/**
- * @psalm-param S $type
+ * @psalm-param class-string<T> $type
* @param string $type
* @param string $input
* @param string $appId
@@ -91,13 +90,16 @@ final class Task implements \JsonSerializable {
}
/**
- * @psalm-param P $provider
+ * @psalm-param IProvider<T> $provider
* @param IProvider $provider
* @return string
* @since 27.1.0
*/
public function visitProvider(IProvider $provider): string {
if ($this->canUseProvider($provider)) {
+ if ($provider instanceof IProviderWithUserId) {
+ $provider->setUserId($this->getUserId());
+ }
return $provider->process($this->getInput());
} else {
throw new \RuntimeException('Task of type ' . $this->getType() . ' cannot visit provider with task type ' . $provider->getTaskType());
@@ -105,7 +107,7 @@ final class Task implements \JsonSerializable {
}
/**
- * @psalm-param P $provider
+ * @psalm-param IProvider<T> $provider
* @param IProvider $provider
* @return bool
* @since 27.1.0
@@ -115,7 +117,7 @@ final class Task implements \JsonSerializable {
}
/**
- * @psalm-return S
+ * @psalm-return class-string<T>
* @since 27.1.0
*/
final public function getType(): string {
@@ -203,7 +205,7 @@ final class Task implements \JsonSerializable {
}
/**
- * @psalm-return array{id: ?int, type: S, status: 0|1|2|3|4, userId: ?string, appId: string, input: string, output: ?string, identifier: string}
+ * @psalm-return array{id: ?int, type: class-string<T>, status: 0|1|2|3|4, userId: ?string, appId: string, input: string, output: ?string, identifier: string, completionExpectedAt: ?int}
* @since 27.1.0
*/
public function jsonSerialize(): array {
@@ -216,6 +218,24 @@ final class Task implements \JsonSerializable {
'input' => $this->getInput(),
'output' => $this->getOutput(),
'identifier' => $this->getIdentifier(),
+ 'completionExpectedAt' => $this->getCompletionExpectedAt()?->getTimestamp(),
];
}
+
+ /**
+ * @param null|\DateTime $completionExpectedAt
+ * @return void
+ * @since 28.0.0
+ */
+ final public function setCompletionExpectedAt(?\DateTime $completionExpectedAt): void {
+ $this->completionExpectedAt = $completionExpectedAt;
+ }
+
+ /**
+ * @return \DateTime|null
+ * @since 28.0.0
+ */
+ final public function getCompletionExpectedAt(): ?\DateTime {
+ return $this->completionExpectedAt;
+ }
}