diff options
Diffstat (limited to 'lib')
26 files changed, 437 insertions, 102 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index acded1ed539..8d20f898dc3 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -49,6 +49,7 @@ return array( 'OCP\\Activity\\Exceptions\\InvalidValueException' => $baseDir . '/lib/public/Activity/Exceptions/InvalidValueException.php', 'OCP\\Activity\\Exceptions\\SettingNotFoundException' => $baseDir . '/lib/public/Activity/Exceptions/SettingNotFoundException.php', 'OCP\\Activity\\Exceptions\\UnknownActivityException' => $baseDir . '/lib/public/Activity/Exceptions/UnknownActivityException.php', + 'OCP\\Activity\\IBulkConsumer' => $baseDir . '/lib/public/Activity/IBulkConsumer.php', 'OCP\\Activity\\IConsumer' => $baseDir . '/lib/public/Activity/IConsumer.php', 'OCP\\Activity\\IEvent' => $baseDir . '/lib/public/Activity/IEvent.php', 'OCP\\Activity\\IEventMerger' => $baseDir . '/lib/public/Activity/IEventMerger.php', @@ -738,6 +739,7 @@ return array( 'OCP\\SabrePluginEvent' => $baseDir . '/lib/public/SabrePluginEvent.php', 'OCP\\SabrePluginException' => $baseDir . '/lib/public/SabrePluginException.php', 'OCP\\Search\\FilterDefinition' => $baseDir . '/lib/public/Search/FilterDefinition.php', + 'OCP\\Search\\IExternalProvider' => $baseDir . '/lib/public/Search/IExternalProvider.php', 'OCP\\Search\\IFilter' => $baseDir . '/lib/public/Search/IFilter.php', 'OCP\\Search\\IFilterCollection' => $baseDir . '/lib/public/Search/IFilterCollection.php', 'OCP\\Search\\IFilteringProvider' => $baseDir . '/lib/public/Search/IFilteringProvider.php', @@ -1347,6 +1349,7 @@ return array( 'OC\\Core\\Command\\SystemTag\\Delete' => $baseDir . '/core/Command/SystemTag/Delete.php', 'OC\\Core\\Command\\SystemTag\\Edit' => $baseDir . '/core/Command/SystemTag/Edit.php', 'OC\\Core\\Command\\SystemTag\\ListCommand' => $baseDir . '/core/Command/SystemTag/ListCommand.php', + 'OC\\Core\\Command\\TaskProcessing\\Cleanup' => $baseDir . '/core/Command/TaskProcessing/Cleanup.php', 'OC\\Core\\Command\\TaskProcessing\\EnabledCommand' => $baseDir . '/core/Command/TaskProcessing/EnabledCommand.php', 'OC\\Core\\Command\\TaskProcessing\\GetCommand' => $baseDir . '/core/Command/TaskProcessing/GetCommand.php', 'OC\\Core\\Command\\TaskProcessing\\ListCommand' => $baseDir . '/core/Command/TaskProcessing/ListCommand.php', @@ -1513,6 +1516,7 @@ return array( 'OC\\Core\\Migrations\\Version31000Date20250213102442' => $baseDir . '/core/Migrations/Version31000Date20250213102442.php', 'OC\\Core\\Migrations\\Version32000Date20250620081925' => $baseDir . '/core/Migrations/Version32000Date20250620081925.php', 'OC\\Core\\Migrations\\Version32000Date20250731062008' => $baseDir . '/core/Migrations/Version32000Date20250731062008.php', + 'OC\\Core\\Migrations\\Version32000Date20250806110519' => $baseDir . '/core/Migrations/Version32000Date20250806110519.php', 'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php', 'OC\\Core\\ResponseDefinitions' => $baseDir . '/core/ResponseDefinitions.php', 'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php', @@ -1687,6 +1691,7 @@ return array( 'OC\\Files\\ObjectStore\\AppdataPreviewObjectStoreStorage' => $baseDir . '/lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php', 'OC\\Files\\ObjectStore\\Azure' => $baseDir . '/lib/private/Files/ObjectStore/Azure.php', 'OC\\Files\\ObjectStore\\HomeObjectStoreStorage' => $baseDir . '/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php', + 'OC\\Files\\ObjectStore\\InvalidObjectStoreConfigurationException' => $baseDir . '/lib/private/Files/ObjectStore/InvalidObjectStoreConfigurationException.php', 'OC\\Files\\ObjectStore\\Mapper' => $baseDir . '/lib/private/Files/ObjectStore/Mapper.php', 'OC\\Files\\ObjectStore\\ObjectStoreScanner' => $baseDir . '/lib/private/Files/ObjectStore/ObjectStoreScanner.php', 'OC\\Files\\ObjectStore\\ObjectStoreStorage' => $baseDir . '/lib/private/Files/ObjectStore/ObjectStoreStorage.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index bb20a68eae3..ef0e6d35740 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -90,6 +90,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Activity\\Exceptions\\InvalidValueException' => __DIR__ . '/../../..' . '/lib/public/Activity/Exceptions/InvalidValueException.php', 'OCP\\Activity\\Exceptions\\SettingNotFoundException' => __DIR__ . '/../../..' . '/lib/public/Activity/Exceptions/SettingNotFoundException.php', 'OCP\\Activity\\Exceptions\\UnknownActivityException' => __DIR__ . '/../../..' . '/lib/public/Activity/Exceptions/UnknownActivityException.php', + 'OCP\\Activity\\IBulkConsumer' => __DIR__ . '/../../..' . '/lib/public/Activity/IBulkConsumer.php', 'OCP\\Activity\\IConsumer' => __DIR__ . '/../../..' . '/lib/public/Activity/IConsumer.php', 'OCP\\Activity\\IEvent' => __DIR__ . '/../../..' . '/lib/public/Activity/IEvent.php', 'OCP\\Activity\\IEventMerger' => __DIR__ . '/../../..' . '/lib/public/Activity/IEventMerger.php', @@ -779,6 +780,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\SabrePluginEvent' => __DIR__ . '/../../..' . '/lib/public/SabrePluginEvent.php', 'OCP\\SabrePluginException' => __DIR__ . '/../../..' . '/lib/public/SabrePluginException.php', 'OCP\\Search\\FilterDefinition' => __DIR__ . '/../../..' . '/lib/public/Search/FilterDefinition.php', + 'OCP\\Search\\IExternalProvider' => __DIR__ . '/../../..' . '/lib/public/Search/IExternalProvider.php', 'OCP\\Search\\IFilter' => __DIR__ . '/../../..' . '/lib/public/Search/IFilter.php', 'OCP\\Search\\IFilterCollection' => __DIR__ . '/../../..' . '/lib/public/Search/IFilterCollection.php', 'OCP\\Search\\IFilteringProvider' => __DIR__ . '/../../..' . '/lib/public/Search/IFilteringProvider.php', @@ -1388,6 +1390,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Core\\Command\\SystemTag\\Delete' => __DIR__ . '/../../..' . '/core/Command/SystemTag/Delete.php', 'OC\\Core\\Command\\SystemTag\\Edit' => __DIR__ . '/../../..' . '/core/Command/SystemTag/Edit.php', 'OC\\Core\\Command\\SystemTag\\ListCommand' => __DIR__ . '/../../..' . '/core/Command/SystemTag/ListCommand.php', + 'OC\\Core\\Command\\TaskProcessing\\Cleanup' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/Cleanup.php', 'OC\\Core\\Command\\TaskProcessing\\EnabledCommand' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/EnabledCommand.php', 'OC\\Core\\Command\\TaskProcessing\\GetCommand' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/GetCommand.php', 'OC\\Core\\Command\\TaskProcessing\\ListCommand' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/ListCommand.php', @@ -1554,6 +1557,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Core\\Migrations\\Version31000Date20250213102442' => __DIR__ . '/../../..' . '/core/Migrations/Version31000Date20250213102442.php', 'OC\\Core\\Migrations\\Version32000Date20250620081925' => __DIR__ . '/../../..' . '/core/Migrations/Version32000Date20250620081925.php', 'OC\\Core\\Migrations\\Version32000Date20250731062008' => __DIR__ . '/../../..' . '/core/Migrations/Version32000Date20250731062008.php', + 'OC\\Core\\Migrations\\Version32000Date20250806110519' => __DIR__ . '/../../..' . '/core/Migrations/Version32000Date20250806110519.php', 'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php', 'OC\\Core\\ResponseDefinitions' => __DIR__ . '/../../..' . '/core/ResponseDefinitions.php', 'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php', @@ -1728,6 +1732,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Files\\ObjectStore\\AppdataPreviewObjectStoreStorage' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/AppdataPreviewObjectStoreStorage.php', 'OC\\Files\\ObjectStore\\Azure' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/Azure.php', 'OC\\Files\\ObjectStore\\HomeObjectStoreStorage' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php', + 'OC\\Files\\ObjectStore\\InvalidObjectStoreConfigurationException' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/InvalidObjectStoreConfigurationException.php', 'OC\\Files\\ObjectStore\\Mapper' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/Mapper.php', 'OC\\Files\\ObjectStore\\ObjectStoreScanner' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/ObjectStoreScanner.php', 'OC\\Files\\ObjectStore\\ObjectStoreStorage' => __DIR__ . '/../../..' . '/lib/private/Files/ObjectStore/ObjectStoreStorage.php', diff --git a/lib/l10n/sr.js b/lib/l10n/sr.js index ac9d3bb0520..42f9cdf5fdb 100644 --- a/lib/l10n/sr.js +++ b/lib/l10n/sr.js @@ -129,6 +129,8 @@ OC.L10N.register( "Settings" : "Поставке", "Log out" : "Одјава", "Accounts" : "Налози", + "Bluesky" : "Bluesky", + "View %s on Bluesky" : "Прикажи %s на Bluesky", "Email" : "Е-пошта", "Mail %s" : "Пошта %s", "Fediverse" : "Fediverse", diff --git a/lib/l10n/sr.json b/lib/l10n/sr.json index 0cf5937a91d..8d5a255ef96 100644 --- a/lib/l10n/sr.json +++ b/lib/l10n/sr.json @@ -127,6 +127,8 @@ "Settings" : "Поставке", "Log out" : "Одјава", "Accounts" : "Налози", + "Bluesky" : "Bluesky", + "View %s on Bluesky" : "Прикажи %s на Bluesky", "Email" : "Е-пошта", "Mail %s" : "Пошта %s", "Fediverse" : "Fediverse", diff --git a/lib/l10n/sw.js b/lib/l10n/sw.js index aa914220945..293e9450d1d 100644 --- a/lib/l10n/sw.js +++ b/lib/l10n/sw.js @@ -2,9 +2,11 @@ OC.L10N.register( "lib", { "Other activities" : "Other activities", + "%1$s and %2$s" : "%1$s na %2$s", "Authentication" : "Uthibitisho", "Unknown filetype" : "Aina ya faili haijulikani", "Invalid image" : "Taswira si halisi", + "Avatar image is not square" : "Avatar image is not square", "Files" : "Mafaili", "View profile" : "Angalia wasifu", "Local time: %s" : "Muda wa kawaida: %s", diff --git a/lib/l10n/sw.json b/lib/l10n/sw.json index f0dc60848ce..708f4eb58cb 100644 --- a/lib/l10n/sw.json +++ b/lib/l10n/sw.json @@ -1,8 +1,10 @@ { "translations": { "Other activities" : "Other activities", + "%1$s and %2$s" : "%1$s na %2$s", "Authentication" : "Uthibitisho", "Unknown filetype" : "Aina ya faili haijulikani", "Invalid image" : "Taswira si halisi", + "Avatar image is not square" : "Avatar image is not square", "Files" : "Mafaili", "View profile" : "Angalia wasifu", "Local time: %s" : "Muda wa kawaida: %s", diff --git a/lib/private/Activity/Event.php b/lib/private/Activity/Event.php index 39cdc12b3fb..0ccad1d0a4e 100644 --- a/lib/private/Activity/Event.php +++ b/lib/private/Activity/Event.php @@ -450,7 +450,6 @@ class Event implements IEvent { return $this->getApp() !== '' && $this->getType() !== '' - && $this->getAffectedUser() !== '' && $this->getTimestamp() !== 0 /** * Disabled for BC with old activities diff --git a/lib/private/Activity/Manager.php b/lib/private/Activity/Manager.php index 4e10f8a0c1a..7471b7d708a 100644 --- a/lib/private/Activity/Manager.php +++ b/lib/private/Activity/Manager.php @@ -11,12 +11,14 @@ use OCP\Activity\ActivitySettings; use OCP\Activity\Exceptions\FilterNotFoundException; use OCP\Activity\Exceptions\IncompleteActivityException; use OCP\Activity\Exceptions\SettingNotFoundException; +use OCP\Activity\IBulkConsumer; use OCP\Activity\IConsumer; use OCP\Activity\IEvent; use OCP\Activity\IFilter; use OCP\Activity\IManager; use OCP\Activity\IProvider; use OCP\Activity\ISetting; +use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; use OCP\IL10N; use OCP\IRequest; @@ -46,6 +48,7 @@ class Manager implements IManager { protected IValidator $validator, protected IRichTextFormatter $richTextFormatter, protected IL10N $l10n, + protected ITimeFactory $timeFactory, ) { } @@ -96,6 +99,31 @@ class Manager implements IManager { * {@inheritDoc} */ public function publish(IEvent $event): void { + if ($event->getAuthor() === '' && $this->session->getUser() instanceof IUser) { + $event->setAuthor($this->session->getUser()->getUID()); + } + + if (!$event->getTimestamp()) { + $event->setTimestamp($this->timeFactory->getTime()); + } + + if ($event->getAffectedUser() === '' || !$event->isValid()) { + throw new IncompleteActivityException('The given event is invalid'); + } + + foreach ($this->getConsumers() as $c) { + $c->receive($event); + } + } + + /** + * {@inheritDoc} + */ + public function bulkPublish(IEvent $event, array $affectedUserIds, ISetting $setting): void { + if (empty($affectedUserIds)) { + throw new IncompleteActivityException('The given event is invalid'); + } + if ($event->getAuthor() === '') { if ($this->session->getUser() instanceof IUser) { $event->setAuthor($this->session->getUser()->getUID()); @@ -103,7 +131,7 @@ class Manager implements IManager { } if (!$event->getTimestamp()) { - $event->setTimestamp(time()); + $event->setTimestamp($this->timeFactory->getTime()); } if (!$event->isValid()) { @@ -111,10 +139,17 @@ class Manager implements IManager { } foreach ($this->getConsumers() as $c) { - $c->receive($event); + if ($c instanceof IBulkConsumer) { + $c->bulkReceive($event, $affectedUserIds, $setting); + } + foreach ($affectedUserIds as $affectedUserId) { + $event->setAffectedUser($affectedUserId); + $c->receive($event); + } } } + /** * In order to improve lazy loading a closure can be registered which will be called in case * activity consumers are actually requested diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index d82ec08f362..76afca9dee8 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -415,7 +415,7 @@ class Root extends Folder implements IRootFolder { */ public function getByIdInPath(int $id, string $path): array { $mountCache = $this->getUserMountCache(); - if (strpos($path, '/', 1) > 0) { + if ($path !== '' && strpos($path, '/', 1) > 0) { [, $user] = explode('/', $path); } else { $user = null; diff --git a/lib/private/Files/ObjectStore/InvalidObjectStoreConfigurationException.php b/lib/private/Files/ObjectStore/InvalidObjectStoreConfigurationException.php new file mode 100644 index 00000000000..369182b069d --- /dev/null +++ b/lib/private/Files/ObjectStore/InvalidObjectStoreConfigurationException.php @@ -0,0 +1,13 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2025 Robin Appelman <robin@icewind.nl> + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OC\Files\ObjectStore; + +class InvalidObjectStoreConfigurationException extends \Exception { + +} diff --git a/lib/private/Files/ObjectStore/PrimaryObjectStoreConfig.php b/lib/private/Files/ObjectStore/PrimaryObjectStoreConfig.php index fdfe989addc..ffc33687340 100644 --- a/lib/private/Files/ObjectStore/PrimaryObjectStoreConfig.php +++ b/lib/private/Files/ObjectStore/PrimaryObjectStoreConfig.php @@ -34,9 +34,13 @@ class PrimaryObjectStoreConfig { * @return ?ObjectStoreConfig */ public function getObjectStoreConfigForRoot(): ?array { - $config = $this->getObjectStoreConfig(); + if (!$this->hasObjectStore()) { + return null; + } + + $config = $this->getObjectStoreConfiguration('root'); - if ($config && $config['arguments']['multibucket']) { + if ($config['arguments']['multibucket']) { if (!isset($config['arguments']['bucket'])) { $config['arguments']['bucket'] = ''; } @@ -51,38 +55,102 @@ class PrimaryObjectStoreConfig { * @return ?ObjectStoreConfig */ public function getObjectStoreConfigForUser(IUser $user): ?array { - $config = $this->getObjectStoreConfig(); + if (!$this->hasObjectStore()) { + return null; + } - if ($config && $config['arguments']['multibucket']) { + $store = $this->getObjectStoreForUser($user); + $config = $this->getObjectStoreConfiguration($store); + + if ($config['arguments']['multibucket']) { $config['arguments']['bucket'] = $this->getBucketForUser($user, $config); } return $config; } /** - * @return ?ObjectStoreConfig + * @param string $name + * @return ObjectStoreConfig */ - private function getObjectStoreConfig(): ?array { + public function getObjectStoreConfiguration(string $name): array { + $configs = $this->getObjectStoreConfigs(); + $name = $this->resolveAlias($name); + if (!isset($configs[$name])) { + throw new \Exception("Object store configuration for '$name' not found"); + } + if (is_string($configs[$name])) { + throw new \Exception("Object store configuration for '{$configs[$name]}' not found"); + } + return $configs[$name]; + } + + public function resolveAlias(string $name): string { + $configs = $this->getObjectStoreConfigs(); + + while (isset($configs[$name]) && is_string($configs[$name])) { + $name = $configs[$name]; + } + return $name; + } + + public function hasObjectStore(): bool { + $objectStore = $this->config->getSystemValue('objectstore', null); + $objectStoreMultiBucket = $this->config->getSystemValue('objectstore_multibucket', null); + return $objectStore || $objectStoreMultiBucket; + } + + public function hasMultipleObjectStorages(): bool { + $objectStore = $this->config->getSystemValue('objectstore', []); + return isset($objectStore['default']); + } + + /** + * @return ?array<string, ObjectStoreConfig|string> + * @throws InvalidObjectStoreConfigurationException + */ + public function getObjectStoreConfigs(): ?array { $objectStore = $this->config->getSystemValue('objectstore', null); $objectStoreMultiBucket = $this->config->getSystemValue('objectstore_multibucket', null); // new-style multibucket config uses the same 'objectstore' key but sets `'multibucket' => true`, transparently upgrade older style config if ($objectStoreMultiBucket) { $objectStoreMultiBucket['arguments']['multibucket'] = true; - return $this->validateObjectStoreConfig($objectStoreMultiBucket); + return [ + 'default' => 'server1', + 'server1' => $this->validateObjectStoreConfig($objectStoreMultiBucket), + 'root' => 'server1', + ]; } elseif ($objectStore) { - return $this->validateObjectStoreConfig($objectStore); + if (!isset($objectStore['default'])) { + $objectStore = [ + 'default' => 'server1', + 'root' => 'server1', + 'server1' => $objectStore, + ]; + } + if (!isset($objectStore['root'])) { + $objectStore['root'] = 'default'; + } + + if (!is_string($objectStore['default'])) { + throw new InvalidObjectStoreConfigurationException('The \'default\' object storage configuration is required to be a reference to another configuration.'); + } + return array_map($this->validateObjectStoreConfig(...), $objectStore); } else { return null; } } /** - * @return ObjectStoreConfig + * @param array|string $config + * @return string|ObjectStoreConfig */ - private function validateObjectStoreConfig(array $config) { + private function validateObjectStoreConfig(array|string $config): array|string { + if (is_string($config)) { + return $config; + } if (!isset($config['class'])) { - throw new \Exception('No class configured for object store'); + throw new InvalidObjectStoreConfigurationException('No class configured for object store'); } if (!isset($config['arguments'])) { $config['arguments'] = []; @@ -90,17 +158,17 @@ class PrimaryObjectStoreConfig { $class = $config['class']; $arguments = $config['arguments']; if (!is_array($arguments)) { - throw new \Exception('Configured object store arguments are not an array'); + throw new InvalidObjectStoreConfigurationException('Configured object store arguments are not an array'); } if (!isset($arguments['multibucket'])) { $arguments['multibucket'] = false; } if (!is_bool($arguments['multibucket'])) { - throw new \Exception('arguments.multibucket must be a boolean in object store configuration'); + throw new InvalidObjectStoreConfigurationException('arguments.multibucket must be a boolean in object store configuration'); } if (!is_string($class)) { - throw new \Exception('Configured class for object store is not a string'); + throw new InvalidObjectStoreConfigurationException('Configured class for object store is not a string'); } if (str_starts_with($class, 'OCA\\') && substr_count($class, '\\') >= 2) { @@ -109,7 +177,7 @@ class PrimaryObjectStoreConfig { } if (!is_a($class, IObjectStore::class, true)) { - throw new \Exception('Configured class for object store is not an object store'); + throw new InvalidObjectStoreConfigurationException('Configured class for object store is not an object store'); } return [ 'class' => $class, @@ -117,8 +185,8 @@ class PrimaryObjectStoreConfig { ]; } - private function getBucketForUser(IUser $user, array $config): string { - $bucket = $this->config->getUserValue($user->getUID(), 'homeobjectstore', 'bucket', null); + public function getBucketForUser(IUser $user, array $config): string { + $bucket = $this->getSetBucketForUser($user); if ($bucket === null) { /* @@ -129,7 +197,7 @@ class PrimaryObjectStoreConfig { $config['arguments']['bucket'] = ''; } $mapper = new Mapper($user, $this->config); - $numBuckets = isset($config['arguments']['num_buckets']) ? $config['arguments']['num_buckets'] : 64; + $numBuckets = $config['arguments']['num_buckets'] ?? 64; $bucket = $config['arguments']['bucket'] . $mapper->getBucket($numBuckets); $this->config->setUserValue($user->getUID(), 'homeobjectstore', 'bucket', $bucket); @@ -137,4 +205,21 @@ class PrimaryObjectStoreConfig { return $bucket; } + + public function getSetBucketForUser(IUser $user): ?string { + return $this->config->getUserValue($user->getUID(), 'homeobjectstore', 'bucket', null); + } + + public function getObjectStoreForUser(IUser $user): string { + if ($this->hasMultipleObjectStorages()) { + $value = $this->config->getUserValue($user->getUID(), 'homeobjectstore', 'objectstore', null); + if ($value === null) { + $value = $this->resolveAlias('default'); + $this->config->setUserValue($user->getUID(), 'homeobjectstore', 'objectstore', $value); + } + return $value; + } else { + return 'default'; + } + } } diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 63eecf5e1d6..a852f453963 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1828,43 +1828,25 @@ class View { * @return string * @throws NotFoundException */ - public function getPath($id, ?int $storageId = null) { + public function getPath($id, ?int $storageId = null): string { $id = (int)$id; - $manager = Filesystem::getMountManager(); - $mounts = $manager->findIn($this->fakeRoot); - $mounts[] = $manager->find($this->fakeRoot); - $mounts = array_filter($mounts); - // reverse the array, so we start with the storage this view is in - // which is the most likely to contain the file we're looking for - $mounts = array_reverse($mounts); - - // put non-shared mounts in front of the shared mount - // this prevents unneeded recursion into shares - usort($mounts, function (IMountPoint $a, IMountPoint $b) { - return $a instanceof SharedMount && (!$b instanceof SharedMount) ? 1 : -1; - }); + $rootFolder = Server::get(Files\IRootFolder::class); - if (!is_null($storageId)) { - $mounts = array_filter($mounts, function (IMountPoint $mount) use ($storageId) { - return $mount->getNumericStorageId() === $storageId; - }); + $node = $rootFolder->getFirstNodeByIdInPath($id, $this->getRoot()); + if ($node) { + if ($storageId === null || $storageId === $node->getStorage()->getCache()->getNumericStorageId()) { + return $this->getRelativePath($node->getPath()) ?? ''; + } + } else { + throw new NotFoundException(sprintf('File with id "%s" has not been found.', $id)); } - foreach ($mounts as $mount) { - /** - * @var \OC\Files\Mount\MountPoint $mount - */ - if ($mount->getStorage()) { - $cache = $mount->getStorage()->getCache(); - $internalPath = $cache->getPathById($id); - if (is_string($internalPath)) { - $fullPath = $mount->getMountPoint() . $internalPath; - if (!is_null($path = $this->getRelativePath($fullPath))) { - return $path; - } - } + foreach ($rootFolder->getByIdInPath($id, $this->getRoot()) as $node) { + if ($storageId === $node->getStorage()->getCache()->getNumericStorageId()) { + return $this->getRelativePath($node->getPath()) ?? ''; } } + throw new NotFoundException(sprintf('File with id "%s" has not been found.', $id)); } diff --git a/lib/private/Search/SearchComposer.php b/lib/private/Search/SearchComposer.php index 77d7ca62311..be366e8ba6c 100644 --- a/lib/private/Search/SearchComposer.php +++ b/lib/private/Search/SearchComposer.php @@ -15,6 +15,7 @@ use OCP\IAppConfig; use OCP\IURLGenerator; use OCP\IUser; use OCP\Search\FilterDefinition; +use OCP\Search\IExternalProvider; use OCP\Search\IFilter; use OCP\Search\IFilteringProvider; use OCP\Search\IInAppSearch; @@ -118,7 +119,7 @@ class SearchComposer { } } - $this->providers = $this->filterProviders($this->providers); + $this->filterProviders(); $this->loadFilters(); } @@ -178,6 +179,7 @@ class SearchComposer { if ($order === null) { return; } + $isExternalProvider = $provider instanceof IExternalProvider ? $provider->isExternalProvider() : false; $triggers = [$provider->getId()]; if ($provider instanceof IFilteringProvider) { $triggers += $provider->getAlternateIds(); @@ -192,6 +194,7 @@ class SearchComposer { 'name' => $provider->getName(), 'icon' => $this->fetchIcon($appId, $provider->getId()), 'order' => $order, + 'isExternalProvider' => $isExternalProvider, 'triggers' => array_values($triggers), 'filters' => $this->getFiltersType($filters, $provider->getId()), 'inAppSearch' => $provider instanceof IInAppSearch, @@ -211,19 +214,21 @@ class SearchComposer { /** * Filter providers based on 'unified_search.providers_allowed' core app config array - * @param array $providers - * @return array + * Will remove providers that are not in the allowed list */ - private function filterProviders(array $providers): array { + private function filterProviders(): void { $allowedProviders = $this->appConfig->getValueArray('core', 'unified_search.providers_allowed'); if (empty($allowedProviders)) { - return $providers; + return; } - return array_values(array_filter($providers, function ($p) use ($allowedProviders) { - return in_array($p['id'], $allowedProviders); - })); + foreach (array_keys($this->providers) as $providerId) { + if (!in_array($providerId, $allowedProviders, true)) { + unset($this->providers[$providerId]); + unset($this->handlers[$providerId]); + } + } } private function fetchIcon(string $appId, string $providerId): string { diff --git a/lib/private/Server.php b/lib/private/Server.php index 171fee2afa1..22cd13438b8 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -657,7 +657,8 @@ class Server extends ServerContainer implements IServerContainer { $c->get(\OCP\IConfig::class), $c->get(IValidator::class), $c->get(IRichTextFormatter::class), - $l10n + $l10n, + $c->get(ITimeFactory::class), ); }); diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 855bb173d56..28f29d6b20f 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1778,7 +1778,7 @@ class Manager implements IManager { } } } - return $this->config->getAppValue('core', 'shareapi_enforce_links_password', 'no') === 'yes'; + return $this->appConfig->getValueBool('core', ConfigLexicon::SHARE_LINK_PASSWORD_ENFORCED); } /** diff --git a/lib/private/TaskProcessing/Db/Task.php b/lib/private/TaskProcessing/Db/Task.php index 4d919deaf94..05c0ae9ac74 100644 --- a/lib/private/TaskProcessing/Db/Task.php +++ b/lib/private/TaskProcessing/Db/Task.php @@ -45,6 +45,8 @@ use OCP\TaskProcessing\Task as OCPTask; * @method int getStartedAt() * @method setEndedAt(int $endedAt) * @method int getEndedAt() + * @method setAllowCleanup(int $allowCleanup) + * @method int getAllowCleanup() */ class Task extends Entity { protected $lastUpdated; @@ -63,16 +65,17 @@ class Task extends Entity { protected $scheduledAt; protected $startedAt; protected $endedAt; + protected $allowCleanup; /** * @var string[] */ - public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id', 'custom_id', 'completion_expected_at', 'error_message', 'progress', 'webhook_uri', 'webhook_method', 'scheduled_at', 'started_at', 'ended_at']; + public static array $columns = ['id', 'last_updated', 'type', 'input', 'output', 'status', 'user_id', 'app_id', 'custom_id', 'completion_expected_at', 'error_message', 'progress', 'webhook_uri', 'webhook_method', 'scheduled_at', 'started_at', 'ended_at', 'allow_cleanup']; /** * @var string[] */ - public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId', 'customId', 'completionExpectedAt', 'errorMessage', 'progress', 'webhookUri', 'webhookMethod', 'scheduledAt', 'startedAt', 'endedAt']; + public static array $fields = ['id', 'lastUpdated', 'type', 'input', 'output', 'status', 'userId', 'appId', 'customId', 'completionExpectedAt', 'errorMessage', 'progress', 'webhookUri', 'webhookMethod', 'scheduledAt', 'startedAt', 'endedAt', 'allowCleanup']; public function __construct() { @@ -94,6 +97,7 @@ class Task extends Entity { $this->addType('scheduledAt', 'integer'); $this->addType('startedAt', 'integer'); $this->addType('endedAt', 'integer'); + $this->addType('allowCleanup', 'integer'); } public function toRow(): array { @@ -122,6 +126,7 @@ class Task extends Entity { 'scheduledAt' => $task->getScheduledAt(), 'startedAt' => $task->getStartedAt(), 'endedAt' => $task->getEndedAt(), + 'allowCleanup' => $task->getAllowCleanup() ? 1 : 0, ]); return $taskEntity; } @@ -144,6 +149,7 @@ class Task extends Entity { $task->setScheduledAt($this->getScheduledAt()); $task->setStartedAt($this->getStartedAt()); $task->setEndedAt($this->getEndedAt()); + $task->setAllowCleanup($this->getAllowCleanup() !== 0); return $task; } } diff --git a/lib/private/TaskProcessing/Db/TaskMapper.php b/lib/private/TaskProcessing/Db/TaskMapper.php index 91fd68820ae..fee96534633 100644 --- a/lib/private/TaskProcessing/Db/TaskMapper.php +++ b/lib/private/TaskProcessing/Db/TaskMapper.php @@ -183,16 +183,39 @@ class TaskMapper extends QBMapper { /** * @param int $timeout + * @param bool $force If true, ignore the allow_cleanup flag * @return int the number of deleted tasks * @throws Exception */ - public function deleteOlderThan(int $timeout): int { + public function deleteOlderThan(int $timeout, bool $force = false): int { $qb = $this->db->getQueryBuilder(); $qb->delete($this->tableName) ->where($qb->expr()->lt('last_updated', $qb->createPositionalParameter($this->timeFactory->getDateTime()->getTimestamp() - $timeout))); + if (!$force) { + $qb->andWhere($qb->expr()->eq('allow_cleanup', $qb->createPositionalParameter(1, IQueryBuilder::PARAM_INT))); + } return $qb->executeStatement(); } + /** + * @param int $timeout + * @param bool $force If true, ignore the allow_cleanup flag + * @return \Generator<Task> + * @throws Exception + */ + public function getTasksToCleanup(int $timeout, bool $force = false): \Generator { + $qb = $this->db->getQueryBuilder(); + $qb->select(Task::$columns) + ->from($this->tableName) + ->where($qb->expr()->lt('last_updated', $qb->createPositionalParameter($this->timeFactory->getDateTime()->getTimestamp() - $timeout))); + if (!$force) { + $qb->andWhere($qb->expr()->eq('allow_cleanup', $qb->createPositionalParameter(1, IQueryBuilder::PARAM_INT))); + } + foreach ($this->yieldEntities($qb) as $entity) { + yield $entity; + }; + } + public function update(Entity $entity): Entity { $entity->setLastUpdated($this->timeFactory->now()->getTimestamp()); return parent::update($entity); diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index 11fb2bed559..e288f2981a8 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -30,6 +30,7 @@ use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotPermittedException; use OCP\Files\SimpleFS\ISimpleFile; +use OCP\Files\SimpleFS\ISimpleFolder; use OCP\Http\Client\IClientService; use OCP\IAppConfig; use OCP\ICache; @@ -78,6 +79,8 @@ class Manager implements IManager { 'ai.taskprocessing_provider_preferences', ]; + public const MAX_TASK_AGE_SECONDS = 60 * 60 * 24 * 30 * 4; // 4 months + /** @var list<IProvider>|null */ private ?array $providers = null; @@ -1449,6 +1452,97 @@ class Manager implements IManager { } /** + * @param Task $task + * @return list<int> + * @throws NotFoundException + */ + public function extractFileIdsFromTask(Task $task): array { + $ids = []; + $taskTypes = $this->getAvailableTaskTypes(); + if (!isset($taskTypes[$task->getTaskTypeId()])) { + throw new NotFoundException('Could not find task type'); + } + $taskType = $taskTypes[$task->getTaskTypeId()]; + foreach ($taskType['inputShape'] + $taskType['optionalInputShape'] as $key => $descriptor) { + if (in_array(EShapeType::getScalarType($descriptor->getShapeType()), [EShapeType::File, EShapeType::Image, EShapeType::Audio, EShapeType::Video], true)) { + /** @var int|list<int> $inputSlot */ + $inputSlot = $task->getInput()[$key]; + if (is_array($inputSlot)) { + $ids = array_merge($inputSlot, $ids); + } else { + $ids[] = $inputSlot; + } + } + } + if ($task->getOutput() !== null) { + foreach ($taskType['outputShape'] + $taskType['optionalOutputShape'] as $key => $descriptor) { + if (in_array(EShapeType::getScalarType($descriptor->getShapeType()), [EShapeType::File, EShapeType::Image, EShapeType::Audio, EShapeType::Video], true)) { + /** @var int|list<int> $outputSlot */ + $outputSlot = $task->getOutput()[$key]; + if (is_array($outputSlot)) { + $ids = array_merge($outputSlot, $ids); + } else { + $ids[] = $outputSlot; + } + } + } + } + return $ids; + } + + /** + * @param ISimpleFolder $folder + * @param int $ageInSeconds + * @return \Generator + */ + public function clearFilesOlderThan(ISimpleFolder $folder, int $ageInSeconds = self::MAX_TASK_AGE_SECONDS): \Generator { + foreach ($folder->getDirectoryListing() as $file) { + if ($file->getMTime() < time() - $ageInSeconds) { + try { + $fileName = $file->getName(); + $file->delete(); + yield $fileName; + } catch (NotPermittedException $e) { + $this->logger->warning('Failed to delete a stale task processing file', ['exception' => $e]); + } + } + } + } + + /** + * @param int $ageInSeconds + * @return \Generator + * @throws Exception + * @throws InvalidPathException + * @throws NotFoundException + * @throws \JsonException + * @throws \OCP\Files\NotFoundException + */ + public function cleanupTaskProcessingTaskFiles(int $ageInSeconds = self::MAX_TASK_AGE_SECONDS): \Generator { + $taskIdsToCleanup = []; + foreach ($this->taskMapper->getTasksToCleanup($ageInSeconds) as $task) { + $taskIdsToCleanup[] = $task->getId(); + $ocpTask = $task->toPublicTask(); + $fileIds = $this->extractFileIdsFromTask($ocpTask); + foreach ($fileIds as $fileId) { + // only look for output files stored in appData/TaskProcessing/ + $file = $this->rootFolder->getFirstNodeByIdInPath($fileId, '/' . $this->rootFolder->getAppDataDirectoryName() . '/core/TaskProcessing/'); + if ($file instanceof File) { + try { + $fileId = $file->getId(); + $fileName = $file->getName(); + $file->delete(); + yield ['task_id' => $task->getId(), 'file_id' => $fileId, 'file_name' => $fileName]; + } catch (NotPermittedException $e) { + $this->logger->warning('Failed to delete a stale task processing file', ['exception' => $e]); + } + } + } + } + return $taskIdsToCleanup; + } + + /** * Make a request to the task's webhookUri if necessary * * @param Task $task diff --git a/lib/private/TaskProcessing/RemoveOldTasksBackgroundJob.php b/lib/private/TaskProcessing/RemoveOldTasksBackgroundJob.php index 42d073a024d..52fc204b752 100644 --- a/lib/private/TaskProcessing/RemoveOldTasksBackgroundJob.php +++ b/lib/private/TaskProcessing/RemoveOldTasksBackgroundJob.php @@ -10,17 +10,14 @@ use OC\TaskProcessing\Db\TaskMapper; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\TimedJob; use OCP\Files\AppData\IAppDataFactory; -use OCP\Files\NotFoundException; -use OCP\Files\NotPermittedException; -use OCP\Files\SimpleFS\ISimpleFolder; use Psr\Log\LoggerInterface; class RemoveOldTasksBackgroundJob extends TimedJob { - public const MAX_TASK_AGE_SECONDS = 60 * 60 * 24 * 30 * 4; // 4 months private \OCP\Files\IAppData $appData; public function __construct( ITimeFactory $timeFactory, + private Manager $taskProcessingManager, private TaskMapper $taskMapper, private LoggerInterface $logger, IAppDataFactory $appDataFactory, @@ -32,48 +29,29 @@ class RemoveOldTasksBackgroundJob extends TimedJob { $this->appData = $appDataFactory->get('core'); } - /** * @inheritDoc */ protected function run($argument): void { try { - $this->taskMapper->deleteOlderThan(self::MAX_TASK_AGE_SECONDS); - } catch (\OCP\DB\Exception $e) { - $this->logger->warning('Failed to delete stale task processing tasks', ['exception' => $e]); + iterator_to_array($this->taskProcessingManager->cleanupTaskProcessingTaskFiles()); + } catch (\Exception $e) { + $this->logger->warning('Failed to delete stale task processing tasks files', ['exception' => $e]); } try { - $this->clearFilesOlderThan($this->appData->getFolder('text2image'), self::MAX_TASK_AGE_SECONDS); - } catch (NotFoundException $e) { - // noop + $this->taskMapper->deleteOlderThan(Manager::MAX_TASK_AGE_SECONDS); + } catch (\OCP\DB\Exception $e) { + $this->logger->warning('Failed to delete stale task processing tasks', ['exception' => $e]); } try { - $this->clearFilesOlderThan($this->appData->getFolder('audio2text'), self::MAX_TASK_AGE_SECONDS); - } catch (NotFoundException $e) { + iterator_to_array($this->taskProcessingManager->clearFilesOlderThan($this->appData->getFolder('text2image'))); + } catch (\OCP\Files\NotFoundException $e) { // noop } try { - $this->clearFilesOlderThan($this->appData->getFolder('TaskProcessing'), self::MAX_TASK_AGE_SECONDS); - } catch (NotFoundException $e) { + iterator_to_array($this->taskProcessingManager->clearFilesOlderThan($this->appData->getFolder('audio2text'))); + } catch (\OCP\Files\NotFoundException $e) { // noop } } - - /** - * @param ISimpleFolder $folder - * @param int $ageInSeconds - * @return void - */ - private function clearFilesOlderThan(ISimpleFolder $folder, int $ageInSeconds): void { - foreach ($folder->getDirectoryListing() as $file) { - if ($file->getMTime() < time() - $ageInSeconds) { - try { - $file->delete(); - } catch (NotPermittedException $e) { - $this->logger->warning('Failed to delete a stale task processing file', ['exception' => $e]); - } - } - } - } - } diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index 07e557d0706..044fa8147a0 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -10,6 +10,7 @@ namespace OC\Template; use bantu\IniGetWrapper\IniGetWrapper; use OC\Authentication\Token\IProvider; use OC\CapabilitiesManager; +use OC\Core\AppInfo\ConfigLexicon; use OC\Files\FilenameValidator; use OC\Share\Share; use OCA\Provisioning_API\Controller\AUserDataOCSController; @@ -22,6 +23,7 @@ use OCP\Authentication\Token\IToken; use OCP\Constants; use OCP\Defaults; use OCP\Files\FileInfo; +use OCP\IAppConfig; use OCP\IConfig; use OCP\IGroupManager; use OCP\IInitialStateService; @@ -50,6 +52,7 @@ class JSConfigHelper { protected ISession $session, protected ?IUser $currentUser, protected IConfig $config, + protected readonly IAppConfig $appConfig, protected IGroupManager $groupManager, protected IniGetWrapper $iniWrapper, protected IURLGenerator $urlGenerator, @@ -94,8 +97,7 @@ class JSConfigHelper { } } - $enableLinkPasswordByDefault = $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'); - $enableLinkPasswordByDefault = $enableLinkPasswordByDefault === 'yes'; + $enableLinkPasswordByDefault = $this->appConfig->getValueBool('core', ConfigLexicon::SHARE_LINK_PASSWORD_DEFAULT); $defaultExpireDateEnabled = $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no') === 'yes'; $defaultExpireDate = $enforceDefaultExpireDate = null; if ($defaultExpireDateEnabled) { diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index cfc387d2164..42861eddc0d 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -20,6 +20,7 @@ use OC\Template\JSResourceLocator; use OCP\App\IAppManager; use OCP\AppFramework\Http\TemplateResponse; use OCP\Defaults; +use OCP\IAppConfig; use OCP\IConfig; use OCP\IInitialStateService; use OCP\INavigationManager; @@ -44,6 +45,7 @@ class TemplateLayout { public function __construct( private IConfig $config, + private readonly IAppConfig $appConfig, private IAppManager $appManager, private InitialStateService $initialState, private INavigationManager $navigationManager, @@ -223,6 +225,7 @@ class TemplateLayout { \OC::$server->getSession(), \OC::$server->getUserSession()->getUser(), $this->config, + $this->appConfig, \OC::$server->getGroupManager(), \OC::$server->get(IniGetWrapper::class), \OC::$server->getURLGenerator(), diff --git a/lib/public/Activity/IBulkConsumer.php b/lib/public/Activity/IBulkConsumer.php new file mode 100644 index 00000000000..9fdf3516b9a --- /dev/null +++ b/lib/public/Activity/IBulkConsumer.php @@ -0,0 +1,24 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OCP\Activity; + +/** + * Interface IBulkConsumer + * + * @since 32.0.0 + */ +interface IBulkConsumer extends IConsumer { + /** + * @param IEvent $event + * @param array $affectedUserIds + * @param ISetting $setting + * @return void + * @since 32.0.0 + */ + public function bulkReceive(IEvent $event, array $affectedUserIds, ISetting $setting): void; +} diff --git a/lib/public/Activity/IManager.php b/lib/public/Activity/IManager.php index 30020b6eced..d638b8b2c6b 100644 --- a/lib/public/Activity/IManager.php +++ b/lib/public/Activity/IManager.php @@ -52,6 +52,20 @@ interface IManager { public function publish(IEvent $event): void; /** + * Bulk publish an event for multiple users + * taking into account the app specific activity settings + * + * Make sure to call at least the following methods before sending an Event: + * - setApp() + * - setType() + * + * @param IEvent $event + * @throws IncompleteActivityException if required values have not been set + * @since 32.0.0 + */ + public function bulkPublish(IEvent $event, array $affectedUserIds, ISetting $setting): void; + + /** * In order to improve lazy loading a closure can be registered which will be called in case * activity consumers are actually requested * diff --git a/lib/public/Search/IExternalProvider.php b/lib/public/Search/IExternalProvider.php new file mode 100644 index 00000000000..a9a8e3ad6ba --- /dev/null +++ b/lib/public/Search/IExternalProvider.php @@ -0,0 +1,25 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Search; + +/** + * Interface for search providers that forward user queries to external services. + * + * @since 32.0.0 + */ +interface IExternalProvider extends IProvider { + /** + * Indicates whether this search provider queries external (3rd-party) resources. + * This is used by the Unified Search modal filter (toggle switch). By default, searching through external providers is disabled. + * + * @return bool default false + * + * @since 32.0.0 + */ + public function isExternalProvider(): bool; +} diff --git a/lib/public/TaskProcessing/IManager.php b/lib/public/TaskProcessing/IManager.php index 723eca8f615..731250d7aa1 100644 --- a/lib/public/TaskProcessing/IManager.php +++ b/lib/public/TaskProcessing/IManager.php @@ -234,4 +234,14 @@ interface IManager { * @since 30.0.0 */ public function setTaskStatus(Task $task, int $status): void; + + /** + * Extract all input and output file IDs from a task + * + * @param Task $task + * @return list<int> + * @throws NotFoundException + * @since 32.0.0 + */ + public function extractFileIdsFromTask(Task $task): array; } diff --git a/lib/public/TaskProcessing/Task.php b/lib/public/TaskProcessing/Task.php index 71c271cd43d..06dc84d59ff 100644 --- a/lib/public/TaskProcessing/Task.php +++ b/lib/public/TaskProcessing/Task.php @@ -66,6 +66,7 @@ final class Task implements \JsonSerializable { protected ?int $scheduledAt = null; protected ?int $startedAt = null; protected ?int $endedAt = null; + protected bool $allowCleanup = true; /** * @param string $taskTypeId @@ -253,7 +254,23 @@ final class Task implements \JsonSerializable { } /** - * @psalm-return array{id: int, lastUpdated: int, type: string, status: 'STATUS_CANCELLED'|'STATUS_FAILED'|'STATUS_SUCCESSFUL'|'STATUS_RUNNING'|'STATUS_SCHEDULED'|'STATUS_UNKNOWN', userId: ?string, appId: string, input: array<string, list<numeric|string>|numeric|string>, output: ?array<string, list<numeric|string>|numeric|string>, customId: ?string, completionExpectedAt: ?int, progress: ?float, scheduledAt: ?int, startedAt: ?int, endedAt: ?int} + * @return bool + * @since 32.0.0 + */ + final public function getAllowCleanup(): bool { + return $this->allowCleanup; + } + + /** + * @param bool $allowCleanup + * @since 32.0.0 + */ + final public function setAllowCleanup(bool $allowCleanup): void { + $this->allowCleanup = $allowCleanup; + } + + /** + * @psalm-return array{id: int, lastUpdated: int, type: string, status: 'STATUS_CANCELLED'|'STATUS_FAILED'|'STATUS_SUCCESSFUL'|'STATUS_RUNNING'|'STATUS_SCHEDULED'|'STATUS_UNKNOWN', userId: ?string, appId: string, input: array<string, list<numeric|string>|numeric|string>, output: ?array<string, list<numeric|string>|numeric|string>, customId: ?string, completionExpectedAt: ?int, progress: ?float, scheduledAt: ?int, startedAt: ?int, endedAt: ?int, allowCleanup: bool} * @since 30.0.0 */ final public function jsonSerialize(): array { @@ -272,6 +289,7 @@ final class Task implements \JsonSerializable { 'scheduledAt' => $this->getScheduledAt(), 'startedAt' => $this->getStartedAt(), 'endedAt' => $this->getEndedAt(), + 'allowCleanup' => $this->getAllowCleanup(), ]; } |