aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-03-15 17:53:30 +0100
committerGitHub <noreply@github.com>2024-03-15 17:53:30 +0100
commit77f47ed68f55f95808b577ddad7964027ad328cf (patch)
treedcc41cb381413d6e24c470f62800c33627890576 /lib/private
parent1111c3fafbca80af684456073cad831a0bf0fe89 (diff)
parent76925f15d6d416dd340994b79d921f9d88eae603 (diff)
downloadnextcloud-server-77f47ed68f55f95808b577ddad7964027ad328cf.tar.gz
nextcloud-server-77f47ed68f55f95808b577ddad7964027ad328cf.zip
Merge pull request #43862 from nextcloud/enh/cancel-stt-scheduled-transcription
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/SpeechToText/SpeechToTextManager.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/private/SpeechToText/SpeechToTextManager.php b/lib/private/SpeechToText/SpeechToTextManager.php
index 73efe105b38..10944a0b424 100644
--- a/lib/private/SpeechToText/SpeechToTextManager.php
+++ b/lib/private/SpeechToText/SpeechToTextManager.php
@@ -112,6 +112,24 @@ class SpeechToTextManager implements ISpeechToTextManager {
}
}
+ public function cancelScheduledFileTranscription(File $file, ?string $userId, string $appId): void {
+ try {
+ $jobArguments = [
+ 'fileId' => $file->getId(),
+ 'owner' => $file->getOwner()->getUID(),
+ 'userId' => $userId,
+ 'appId' => $appId,
+ ];
+ if (!$this->jobList->has(TranscriptionJob::class, $jobArguments)) {
+ $this->logger->debug('Failed to cancel a Speech-to-text job for file ' . $file->getId() . '. No related job was found.');
+ return;
+ }
+ $this->jobList->remove(TranscriptionJob::class, $jobArguments);
+ } catch (NotFoundException|InvalidPathException $e) {
+ throw new InvalidArgumentException('Invalid file provided to cancel file transcription: ' . $e->getMessage());
+ }
+ }
+
public function transcribeFile(File $file): string {
if (!$this->hasProviders()) {
throw new PreConditionNotMetException('No SpeechToText providers have been registered');