mirror of
https://github.com/moodle/moodle.git
synced 2025-02-25 04:23:22 +01:00
MDL-80225 mod_bigbluebuttonbn: Fix missing recordings
This commit is contained in:
parent
6cd55074c7
commit
e80fe0c3a4
@ -193,6 +193,31 @@ class recording_proxy extends proxy_base {
|
||||
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.
|
||||
*
|
||||
|
@ -714,13 +714,14 @@ class recording extends persistent {
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user