Skip to content

Commit

Permalink
recordings: code review fixes; cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jrchamp committed Mar 27, 2024
1 parent 4805a6b commit bfaf268
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
27 changes: 17 additions & 10 deletions classes/task/get_meeting_recordings.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,26 @@ public function execute() {
$zoomrecordings = $service->get_user_recordings($hostid, $from, $to);

foreach ($zoomrecordings as $recordingid => $recording) {
if (empty($meetings[$recording->meetingid])) {
// Skip meetings that are not in Moodle.
mtrace('Meeting id: ' . $recording->meetingid . ' does not exist...skipping');
continue;
}

$zoom = $meetings[$recording->meetingid];

if (isset($localrecordings[$recording->meetinguuid][$recordingid])) {
mtrace('Recording id: ' . $recordingid . ' exists...verifying current data.');
if ($localrecordings[$recording->meetinguuid][$recordingid]->name != $meetings[$recording->meetingid]->name) {
$updatemeeting = $localrecordings[$recording->meetinguuid][$recordingid];
$updatemeeting->name = $meetings[$recording->meetingid]->name;
$localrecording = $localrecordings[$recording->meetinguuid][$recordingid];

if ($localrecording->name !== $zoom->name) {
$updatemeeting = (object) [
'id' => $localrecording->id,
'name' => $zoom->name,
];
$DB->update_record('zoom_meeting_recordings', $updatemeeting);
}
continue;
}

if (empty($meetings[$recording->meetingid])) {
// Skip meetings that are not in Moodle.
mtrace('Meeting id: ' . $recording->meetingid . ' does not exist...skipping');
continue;
}

Expand All @@ -130,7 +137,7 @@ public function execute() {
}
}

$zoom = $meetings[$recording->meetingid];
$recordingtype = $recording->recordingtype;

$record = new stdClass();
$record->zoomid = $zoom->id;
Expand All @@ -139,7 +146,7 @@ public function execute() {
$record->name = $zoom->name;
$record->externalurl = $recording->url;
$record->passcode = $meetingpasscodes[$recording->meetinguuid];
$record->recordingtype = $recording->recordingtype;
$record->recordingtype = $recordingtype;
$record->recordingstart = $recording->recordingstart;
$record->showrecording = $zoom->recordings_visible_default;
$record->timecreated = $now;
Expand Down
7 changes: 4 additions & 3 deletions classes/webservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -1005,11 +1005,12 @@ public function get_recording_url_list($meetingid) {

if (!empty($response->recording_files)) {
foreach ($response->recording_files as $recording) {
if (!empty($recording->play_url) && isset($allowedrecordingtypes[$recording->file_type])) {
$url = $recording->play_url ?? $recording->download_url ?? null;
if (!empty($url) && isset($allowedrecordingtypes[$recording->file_type])) {
$recordinginfo = new stdClass();
$recordinginfo->recordingid = $recording->id;
$recordinginfo->meetinguuid = $response->uuid;
$recordinginfo->url = $recording->play_url;
$recordinginfo->url = $url;
$recordinginfo->filetype = $recording->file_type;
$recordinginfo->recordingtype = $recording->recording_type;
$recordinginfo->passcode = $response->password;
Expand Down Expand Up @@ -1062,7 +1063,7 @@ public function get_user_recordings($userid, $from, $to) {
$recordinginfo->recordingid = $recording->id;
$recordinginfo->meetingid = $meeting->id;
$recordinginfo->meetinguuid = $meeting->uuid;
$recordinginfo->url = $recording->play_url;
$recordinginfo->url = $url;
$recordinginfo->filetype = $recording->file_type;
$recordinginfo->recordingtype = $recording->recording_type;
$recordinginfo->recordingstart = strtotime($recording->recording_start);
Expand Down
7 changes: 7 additions & 0 deletions recordings.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@
}
}

/**
* Get the display name for a Zoom recording type.
*
* @package mod_zoom
* @param string $recordingtype Zoom recording type.
* @return string
*/
function zoom_get_recording_type_string($recordingtype) {
$recordingtypestringmap = [
'active_speaker' => 'recordingtype_active_speaker',
Expand Down

0 comments on commit bfaf268

Please sign in to comment.