- Модуль: socialservices
- Путь к файлу: ~/bitrix/modules/socialservices/lib/integration/zoom/conference.php
- Класс: BitrixSocialServicesIntegrationZoomConference
- Вызов: Conference::saveRecordings
static function saveRecordings(int $conferenceId, array $recordingsData, $downloadToken): Result
{
$result = new Result();
if (!Loader::includeModule('socialservices'))
{
return $result->addError(new Error('Module socialservices is not installed.'));
}
if (!is_array($recordingsData['recording_files']))
{
return $result->addError(new Error('Error: recording_files key is not found in recording data'));
}
$meeting = ZoomMeetingTable::getRowByExternalId($conferenceId);
if (!$meeting)
{
return $result->addError(new Error("Meeting {$conferenceId} is not found"));
}
$meetingId = $meeting['ID'];
if ($meeting['HAS_RECORDING'] !== 'Y')
{
ZoomMeetingTable::update($meetingId, [
'HAS_RECODING' => 'Y'
]);
}
$crmInstalled = Loader::includeModule('crm');
foreach ($recordingsData['recording_files'] as $record)
{
$startDateTimestamp = DateTime::createFromFormat(DATE_ATOM, $record['recording_start'])->getTimestamp();
$endDateTimestamp = DateTime::createFromFormat(DATE_ATOM, $record['recording_end'])->getTimestamp();
$recordFields = [
'EXTERNAL_ID' => $record['id'],
'MEETING_ID' => $meetingId, //?
'START_DATE' => DateTime::createFromTimestamp($startDateTimestamp),
'END_DATE' => DateTime::createFromTimestamp($endDateTimestamp),
'FILE_TYPE' => $record['file_type'],
'FILE_SIZE' => (int)$record['file_size'],
'PLAY_URL' => $record['play_url'],
'DOWNLOAD_URL' => $record['download_url'],
'RECORDING_TYPE' => $record['recording_type'],
'DOWNLOAD_TOKEN' => $downloadToken,
'PASSWORD' => $recordingsData['password']
];
$addResult = ZoomMeetingRecordingTable::add($recordFields);
if (!$addResult->isSuccess())
{
return $result->addErrors($addResult->getErrors());
}
$recordingId = $addResult->getId();
if($crmInstalled && $meeting['ENTITY_TYPE_ID'] === static::ACTIVITY_ENTITY_TYPE && $meeting['ENTITY_ID'] > 0)
{
$activityId = (int)$meeting['ENTITY_ID'];
if ($record['recording_type'] === static::ZOOM_AUDIO_ONLY)
{
DownloadAgent::scheduleDownload($activityId, $recordingId);
}
}
}
return $result;
}