diff --git a/lib/Capabilities.php b/lib/Capabilities.php index 23e2776fac0..a82e8e8a78f 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -352,11 +352,11 @@ public function getCapabilities(): array { $capabilities['config']['call']['can-enable-sip'] = $this->talkConfig->canUserEnableSIP($user); } - $supportedTaskTypes = $this->taskProcessingManager->getAvailableTaskTypes(); - if (isset($supportedTaskTypes[TextToTextSummary::ID])) { + $supportedTaskTypeIds = $this->taskProcessingManager->getAvailableTaskTypeIds(); + if (in_array(TextToTextSummary::ID, $supportedTaskTypeIds, true)) { $capabilities['features'][] = 'chat-summary-api'; } - if (isset($supportedTaskTypes[TextToTextTranslate::ID])) { + if (in_array(TextToTextTranslate::ID, $supportedTaskTypeIds, true)) { $capabilities['config']['chat']['has-translation-task-providers'] = true; } diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index 77f985aeb0b..ca0992fb4bc 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -556,8 +556,8 @@ public function summarizeChat( ): DataResponse { $fromMessageId = max(0, $fromMessageId); - $supportedTaskTypes = $this->taskProcessingManager->getAvailableTaskTypes(); - if (!isset($supportedTaskTypes[TextToTextSummary::ID])) { + $supportedTaskTypeIds = $this->taskProcessingManager->getAvailableTaskTypeIds(); + if (!in_array(TextToTextSummary::ID, $supportedTaskTypeIds, true)) { return new DataResponse([ 'error' => ChatSummaryException::REASON_AI_ERROR, ], Http::STATUS_BAD_REQUEST); diff --git a/lib/Service/RecordingService.php b/lib/Service/RecordingService.php index 72ec1b8f3f5..b1e67ecefdb 100644 --- a/lib/Service/RecordingService.php +++ b/lib/Service/RecordingService.php @@ -157,8 +157,8 @@ public function store(Room $room, string $owner, array $file): void { return; } - $supportedTaskTypes = $this->taskProcessingManager->getAvailableTaskTypes(); - if (!isset($supportedTaskTypes[AudioToText::ID])) { + $supportedTaskTypeIds = $this->taskProcessingManager->getAvailableTaskTypeIds(); + if (!in_array(AudioToText::ID, $supportedTaskTypeIds, true)) { $this->logger->error('Can not transcribe call recording as no Audio2Text task provider is available'); return; } @@ -258,8 +258,8 @@ public function storeTranscript(string $owner, string $roomToken, int $recording return; } - $supportedTaskTypes = $this->taskProcessingManager->getAvailableTaskTypes(); - if (!isset($supportedTaskTypes[TextToTextSummary::ID])) { + $supportedTaskTypeIds = $this->taskProcessingManager->getAvailableTaskTypeIds(); + if (!in_array(TextToTextSummary::ID, $supportedTaskTypeIds, true)) { $this->logger->error('Can not summarize call recording as no TextToTextSummary task provider is available'); return; } diff --git a/tests/php/CapabilitiesTest.php b/tests/php/CapabilitiesTest.php index 5f8eead8db6..2dd7d3d8e1c 100644 --- a/tests/php/CapabilitiesTest.php +++ b/tests/php/CapabilitiesTest.php @@ -263,8 +263,8 @@ public function testGetCapabilitiesUserAllowed(bool $isNotAllowed, bool $canCrea $user->method('getQuota') ->willReturn($quota); - $this->taskProcessingManager->method('getAvailableTaskTypes') - ->willReturn([TextToTextSummary::ID => true]); + $this->taskProcessingManager->method('getAvailableTaskTypeIds') + ->willReturn([TextToTextSummary::ID]); $this->serverConfig->expects($this->any()) ->method('getAppValue') @@ -509,8 +509,8 @@ public function testCapabilitiesTranslations(): void { public function testCapabilitiesTranslationsTaskProviders(): void { $capabilities = $this->getCapabilities(); - $this->taskProcessingManager->method('getAvailableTaskTypes') - ->willReturn([TextToTextTranslate::ID => true]); + $this->taskProcessingManager->method('getAvailableTaskTypeIds') + ->willReturn([TextToTextTranslate::ID]); $data = json_decode(json_encode($capabilities->getCapabilities(), JSON_THROW_ON_ERROR), true); $this->assertEquals(true, $data['spreed']['config']['chat']['has-translation-task-providers']); @@ -519,8 +519,8 @@ public function testCapabilitiesTranslationsTaskProviders(): void { public function testSummaryTaskProviders(): void { $capabilities = $this->getCapabilities(); - $this->taskProcessingManager->method('getAvailableTaskTypes') - ->willReturn([TextToTextFormalization::ID => true]); + $this->taskProcessingManager->method('getAvailableTaskTypeIds') + ->willReturn([TextToTextFormalization::ID]); $data = json_decode(json_encode($capabilities->getCapabilities(), JSON_THROW_ON_ERROR), true); $this->assertNotContains('chat-summary-api', $data['spreed']['features']);