From 8cac92665d78304aaeb5e9b521f371960175d3df Mon Sep 17 00:00:00 2001 From: Jana Peper <jana.peper@nextcloud.com> Date: Sun, 8 Dec 2024 19:16:19 +0100 Subject: feat: filter disabled apps in task types requests Signed-off-by: Jana Peper <jana.peper@nextcloud.com> --- lib/private/TaskProcessing/Manager.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/private/TaskProcessing') diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index ffa39912a01..f24b1b73da4 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -564,6 +564,14 @@ class Manager implements IManager { return $taskTypes; } + /** + * @return array + */ + private function _getTaskTypeSettings(): array { + $json = $this->config->getAppValue('core', 'ai.taskprocessing_type_preferences', ''); + return json_decode($json, true); + } + /** * @param ShapeDescriptor[] $spec * @param array<array-key, string|numeric> $defaults @@ -721,12 +729,16 @@ class Manager implements IManager { throw new \OCP\TaskProcessing\Exception\Exception('No matching provider found'); } - public function getAvailableTaskTypes(): array { + public function getAvailableTaskTypes(bool $showDisabled = false): array { if ($this->availableTaskTypes === null) { $taskTypes = $this->_getTaskTypes(); + $taskTypeSettings = $this->_getTaskTypeSettings(); $availableTaskTypes = []; foreach ($taskTypes as $taskType) { + if ((!$showDisabled) && isset($taskTypeSettings[$taskType->getId()]) && !$taskTypeSettings[$taskType->getId()]) { + continue; + } try { $provider = $this->getPreferredProvider($taskType->getId()); } catch (\OCP\TaskProcessing\Exception\Exception $e) { -- cgit v1.2.3