Skip to content

Commit

Permalink
MDL-80225 mod_bigbluebuttonbn: Fix missing recordings
Browse files Browse the repository at this point in the history
  • Loading branch information
ssj365 committed Aug 22, 2024
1 parent fd487cd commit 53802f0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
25 changes: 25 additions & 0 deletions mod/bigbluebuttonbn/classes/local/proxy/recording_proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,31 @@ public static function fetch_recordings(array $keyids = []): array {
return $recordings;
}

/**
* Helper function to retrieve recordings that failed to be fetched from a BigBlueButton server.
*
* @param array $keyids list of recordingids
* @return array array of recording recordingids not fetched from server
* and sorted by {@see recording_proxy::sort_recordings}
*/
public static function fetch_missing_recordings(array $keyids = []): array {
$unfetchedids = [];
$pagesize = 25;
// If $ids is empty return array() to prevent a getRecordings with meetingID and recordID set to ''.
if (empty($keyids)) {
return $unfetchedids;
}
while ($ids = array_splice($keyids, 0, $pagesize)) {
// We make getRecordings API call to check recordings are successfully retrieved.
$xml = self::fetch_endpoint_xml('getRecordings', ['recordID' => implode(',', $ids), 'state' => 'any']);
if (!$xml || $xml->returncode != 'SUCCESS' || !isset($xml->recordings)) {
$unfetchedids = array_merge($unfetchedids, $ids);
continue; // We will keep record of all unfetched ids.
}
}
return $unfetchedids;
}

/**
* Helper function to fetch recordings from a BigBlueButton server.
*
Expand Down
7 changes: 4 additions & 3 deletions mod/bigbluebuttonbn/classes/recording.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,13 +714,14 @@ protected static function fetch_records(array $selects, array $params): array {

// Fetch all metadata for these recordings.
$metadatas = recording_proxy::fetch_recordings($recordingids);
$failedids = recording_proxy::fetch_missing_recordings($recordingids);

// Return the instances.
return array_filter(array_map(function ($recording) use ($metadatas, $withindays) {
return array_filter(array_map(function ($recording) use ($metadatas, $withindays, $failedids) {
// Filter out if no metadata was fetched.
if (!array_key_exists($recording->recordingid, $metadatas)) {
// Mark it as dismissed if it is older than 30 days.
if ($withindays > $recording->timecreated) {
// If the recording was successfully fetched, mark it as dismissed if it is older than 30 days.
if (!in_array($recording->recordingid, $failedids) && $withindays > $recording->timecreated) {
$recording = new self(0, $recording, null);
$recording->set_status(self::RECORDING_STATUS_DISMISSED);
}
Expand Down

0 comments on commit 53802f0

Please sign in to comment.