Introduce ISpeechToTextProviderWithUserId

Signed-off-by: Andrey Borysenko <andrey18106x@gmail.com>
This commit is contained in:
Andrey Borysenko 2024-01-14 18:47:40 +02:00
parent eaa6d96cf7
commit 13588c7566
No known key found for this signature in database
GPG Key ID: 934CB29F9F59B0D1
2 changed files with 43 additions and 0 deletions

View File

@ -36,10 +36,12 @@ use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IServerContainer;
use OCP\IUserSession;
use OCP\PreConditionNotMetException;
use OCP\SpeechToText\ISpeechToTextManager;
use OCP\SpeechToText\ISpeechToTextProvider;
use OCP\SpeechToText\ISpeechToTextProviderWithId;
use OCP\SpeechToText\ISpeechToTextProviderWithUserId;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
@ -56,6 +58,7 @@ class SpeechToTextManager implements ISpeechToTextManager {
private LoggerInterface $logger,
private IJobList $jobList,
private IConfig $config,
private IUserSession $userSession,
) {
}
@ -123,6 +126,9 @@ class SpeechToTextManager implements ISpeechToTextManager {
if ($provider instanceof ISpeechToTextProviderWithId) {
return $provider->getId() === $classNameOrId;
}
if ($provider instanceof ISpeechToTextProviderWithUserId) {
$provider->setUserId($this->userSession->getUser()?->getUID());
}
return $provider::class === $classNameOrId;
}));
if ($provider !== false) {

View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2024 Marcel Klehr <mklehr@gmx.net>
*
* @author Marcel Klehr <mklehr@gmx.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OCP\SpeechToText;
/**
* @since 29.0.0
*/
interface ISpeechToTextProviderWithUserId extends ISpeechToTextProvider {
/**
* @since 29.0.0
*/
public function setUserId(?string $userId): void;
}