fix(recording): Handle the problem gracefully when the recording can not be uploaded

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling
2024-05-08 11:22:42 +02:00
parent f00d7a682f
commit 90747202dc
9 changed files with 94 additions and 18 deletions

View File

@ -19,6 +19,7 @@ use OCA\Talk\Manager;
use OCA\Talk\Participant;
use OCA\Talk\Recording\BackendNotifier;
use OCA\Talk\Room;
use OCP\AppFramework\Services\IAppConfig;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Files\File;
use OCP\Files\Folder;
@ -39,6 +40,8 @@ class RecordingService {
public const CONSENT_REQUIRED_YES = 1;
public const CONSENT_REQUIRED_OPTIONAL = 2;
public const APPCONFIG_PREFIX = 'recording/';
public const DEFAULT_ALLOWED_RECORDING_FORMATS = [
'audio/ogg' => ['ogg'],
'video/ogg' => ['ogv'],
@ -64,6 +67,7 @@ class RecordingService {
protected ITimeFactory $timeFactory,
protected Config $config,
protected IConfig $serverConfig,
protected IAppConfig $appConfig,
protected RoomService $roomService,
protected ShareManager $shareManager,
protected ChatManager $chatManager,
@ -92,6 +96,7 @@ class RecordingService {
$startingStatus = $status === Room::RECORDING_VIDEO ? Room::RECORDING_VIDEO_STARTING : Room::RECORDING_AUDIO_STARTING;
$this->roomService->setCallRecording($room, $startingStatus);
$this->appConfig->setAppValueString(self::APPCONFIG_PREFIX . $room->getToken(), $owner, true, true);
}
public function stop(Room $room, ?Participant $participant = null): void {
@ -110,6 +115,7 @@ class RecordingService {
}
public function store(Room $room, string $owner, array $file): void {
$this->appConfig->deleteAppValue(self::APPCONFIG_PREFIX . $room->getToken());
try {
$participant = $this->participantService->getParticipant($room, $owner);
} catch (ParticipantNotFoundException $e) {
@ -172,6 +178,35 @@ class RecordingService {
}
}
/**
* @throws InvalidArgumentException
*/
public function notifyAboutFailedStore(Room $room): void {
$owner = $this->appConfig->getAppValueString(self::APPCONFIG_PREFIX . $room->getToken(), lazy: true);
if ($owner === '') {
return;
}
try {
$participant = $this->participantService->getParticipant($room, $owner);
} catch (ParticipantNotFoundException) {
$this->logger->warning('Could not determinate conversation when trying to notify about failed upload of call recording');
throw new InvalidArgumentException('owner_participant');
}
$attendee = $participant->getAttendee();
$notification = $this->notificationManager->createNotification();
$notification
->setApp('spreed')
->setDateTime($this->timeFactory->getDateTime())
->setObject('recording_information', $room->getToken())
->setUser($attendee->getActorId())
->setSubject('record_file_store_fail');
$this->notificationManager->notify($notification);
}
public function notifyAboutFailedTranscript(string $owner, File $recording): void {
$recordingFolder = $recording->getParent();
$roomToken = $recordingFolder->getName();