mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-73198 mod_bigbluebuttonbn: restored synchrony of recordings
This commit is contained in:
parent
5ee0b620ae
commit
fbbf30dd04
3 changed files with 49 additions and 19 deletions
|
@ -188,7 +188,6 @@ class recording_proxy extends proxy_base {
|
||||||
|
|
||||||
$recordings += $fetchrecordings;
|
$recordings += $fetchrecordings;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort recordings.
|
// Sort recordings.
|
||||||
return self::sort_recordings($recordings);
|
return self::sort_recordings($recordings);
|
||||||
}
|
}
|
||||||
|
@ -202,7 +201,7 @@ class recording_proxy extends proxy_base {
|
||||||
*/
|
*/
|
||||||
private static function fetch_recordings_page(array $ids, $key = 'recordID'): array {
|
private static function fetch_recordings_page(array $ids, $key = 'recordID'): array {
|
||||||
// The getRecordings call is executed using a method GET (supported by all versions of BBB).
|
// The getRecordings call is executed using a method GET (supported by all versions of BBB).
|
||||||
$xml = self::fetch_endpoint_xml('getRecordings', [$key => implode(',', $ids)]);
|
$xml = self::fetch_endpoint_xml('getRecordings', [$key => implode(',', $ids), 'state' => 'any']);
|
||||||
|
|
||||||
if (!$xml) {
|
if (!$xml) {
|
||||||
return [];
|
return [];
|
||||||
|
@ -293,9 +292,13 @@ class recording_proxy extends proxy_base {
|
||||||
self::parse_recording_meta(get_object_vars($recording->metadata));
|
self::parse_recording_meta(get_object_vars($recording->metadata));
|
||||||
$recordingarray = [
|
$recordingarray = [
|
||||||
'recordID' => (string) $recording->recordID,
|
'recordID' => (string) $recording->recordID,
|
||||||
'meetingID' => (string) $recording->meetingID, 'meetingName' => (string) $recording->name,
|
'meetingID' => (string) $recording->meetingID,
|
||||||
'published' => (string) $recording->published, 'startTime' => (string) $recording->startTime,
|
'meetingName' => (string) $recording->name,
|
||||||
'endTime' => (string) $recording->endTime, 'playbacks' => $playbackarray
|
'published' => (string) $recording->published,
|
||||||
|
'state' => (string) $recording->state,
|
||||||
|
'startTime' => (string) $recording->startTime,
|
||||||
|
'endTime' => (string) $recording->endTime,
|
||||||
|
'playbacks' => $playbackarray
|
||||||
];
|
];
|
||||||
if (isset($recording->protected)) {
|
if (isset($recording->protected)) {
|
||||||
$recordingarray['protected'] = (string) $recording->protected;
|
$recordingarray['protected'] = (string) $recording->protected;
|
||||||
|
|
|
@ -63,12 +63,18 @@ class recording extends persistent {
|
||||||
/** @var int A meeting set to be recorded was processed and set back to an awaiting state */
|
/** @var int A meeting set to be recorded was processed and set back to an awaiting state */
|
||||||
public const RECORDING_STATUS_RESET = 4;
|
public const RECORDING_STATUS_RESET = 4;
|
||||||
|
|
||||||
|
/** @var int A meeting set to be recorded was deleted from bigbluebutton */
|
||||||
|
public const RECORDING_STATUS_DELETED = 5;
|
||||||
|
|
||||||
/** @var bool Whether metadata been changed so the remote information needs to be updated ? */
|
/** @var bool Whether metadata been changed so the remote information needs to be updated ? */
|
||||||
protected $metadatachanged = false;
|
protected $metadatachanged = false;
|
||||||
|
|
||||||
/** @var int A refresh period for recordings, defaults to 300s (5mins) */
|
/** @var int A refresh period for recordings, defaults to 300s (5mins) */
|
||||||
public const RECORDING_REFRESH_DEFAULT_PERIOD = 300;
|
public const RECORDING_REFRESH_DEFAULT_PERIOD = 300;
|
||||||
|
|
||||||
|
/** @var int A time limit for recordings to be dismissed, defaults to 30d (30days) */
|
||||||
|
public const RECORDING_TIME_LIMIT_DAYS = 30;
|
||||||
|
|
||||||
/** @var array A cached copy of the metadata */
|
/** @var array A cached copy of the metadata */
|
||||||
protected $metadata = null;
|
protected $metadata = null;
|
||||||
|
|
||||||
|
@ -493,6 +499,16 @@ class recording extends persistent {
|
||||||
recording_proxy::publish_recording($this->get('recordingid'), $realvalue);
|
recording_proxy::publish_recording($this->get('recordingid'), $realvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update recording status
|
||||||
|
*
|
||||||
|
* @param bool $value
|
||||||
|
*/
|
||||||
|
protected function set_status($value) {
|
||||||
|
$this->raw_set('status', $value);
|
||||||
|
$this->update();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POSSIBLE_REMOTE_META_SOURCE match a field type and its metadataname (historical and current).
|
* POSSIBLE_REMOTE_META_SOURCE match a field type and its metadataname (historical and current).
|
||||||
*/
|
*/
|
||||||
|
@ -683,12 +699,14 @@ class recording extends persistent {
|
||||||
protected static function fetch_records(array $selects, array $params): array {
|
protected static function fetch_records(array $selects, array $params): array {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
|
$withindays = time() - (self::RECORDING_TIME_LIMIT_DAYS * DAYSECS);
|
||||||
|
|
||||||
// Fetch the local data. Arbitrary sort by id, so we get the same result on different db engines.
|
// Fetch the local data. Arbitrary sort by id, so we get the same result on different db engines.
|
||||||
$recordings = $DB->get_records_select(static::TABLE, implode(" AND ", $selects), $params,
|
$recordings = $DB->get_records_select(static::TABLE, implode(" AND ", $selects), $params,
|
||||||
self::DEFAULT_RECORDING_SORT);
|
self::DEFAULT_RECORDING_SORT);
|
||||||
|
|
||||||
// Grab the recording IDs.
|
// Grab the recording IDs.
|
||||||
$recordingids = array_filter(array_map(function($recording) {
|
$recordingids = array_values(array_map(function($recording) {
|
||||||
return $recording->recordingid;
|
return $recording->recordingid;
|
||||||
}, $recordings));
|
}, $recordings));
|
||||||
|
|
||||||
|
@ -696,14 +714,26 @@ class recording extends persistent {
|
||||||
$metadatas = recording_proxy::fetch_recordings($recordingids);
|
$metadatas = recording_proxy::fetch_recordings($recordingids);
|
||||||
|
|
||||||
// Return the instances.
|
// Return the instances.
|
||||||
return array_map(function($recording) use ($metadatas) {
|
return array_filter(array_map(function($recording) use ($metadatas, $withindays) {
|
||||||
$metadata = null;
|
// Filter out if no metadata was fetched.
|
||||||
if (array_key_exists($recording->recordingid, $metadatas)) {
|
if (!array_key_exists($recording->recordingid, $metadatas)) {
|
||||||
$metadata = $metadatas[$recording->recordingid];
|
// Mark it as dismissed if it is older than 30 days.
|
||||||
|
if ($withindays > $recording->timecreated) {
|
||||||
|
$recording = new self(0, $recording, null);
|
||||||
|
$recording->set_status(self::RECORDING_STATUS_DISMISSED);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
$metadata = $metadatas[$recording->recordingid];
|
||||||
|
// Filter out and mark it as deleted if it was deleted in BBB.
|
||||||
|
if ($metadata['state'] == 'deleted') {
|
||||||
|
$recording = new self(0, $recording, null);
|
||||||
|
$recording->set_status(self::RECORDING_STATUS_DELETED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Include it otherwise.
|
||||||
return new self(0, $recording, $metadata);
|
return new self(0, $recording, $metadata);
|
||||||
}, $recordings);
|
}, $recordings));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -748,14 +778,12 @@ class recording extends persistent {
|
||||||
public static function sync_pending_recordings_from_server(): void {
|
public static function sync_pending_recordings_from_server(): void {
|
||||||
global $DB;
|
global $DB;
|
||||||
|
|
||||||
$timelimitdays = 30;
|
|
||||||
|
|
||||||
// Fetch the local data.
|
// Fetch the local data.
|
||||||
mtrace("=> Looking for any recording awaiting processing from the past {$timelimitdays} days.");
|
mtrace("=> Looking for any recording awaiting processing from the past 30 days.");
|
||||||
$select = 'status = :status_awaiting AND timecreated > :withindays OR status = :status_reset';
|
$select = 'status = :status_awaiting AND timecreated > :withindays OR status = :status_reset';
|
||||||
$recordings = $DB->get_records_select(static::TABLE, $select, [
|
$recordings = $DB->get_records_select(static::TABLE, $select, [
|
||||||
'status_awaiting' => self::RECORDING_STATUS_AWAITING,
|
'status_awaiting' => self::RECORDING_STATUS_AWAITING,
|
||||||
'withindays' => time() - ($timelimitdays * DAYSECS),
|
'withindays' => time() - (self::RECORDING_TIME_LIMIT_DAYS * DAYSECS),
|
||||||
'status_reset' => self::RECORDING_STATUS_RESET,
|
'status_reset' => self::RECORDING_STATUS_RESET,
|
||||||
], self::DEFAULT_RECORDING_SORT);
|
], self::DEFAULT_RECORDING_SORT);
|
||||||
// Sort by DEFAULT_RECORDING_SORT we get the same result on different db engines.
|
// Sort by DEFAULT_RECORDING_SORT we get the same result on different db engines.
|
||||||
|
@ -778,8 +806,7 @@ class recording extends persistent {
|
||||||
$id = array_search($recordingid, $recordingids);
|
$id = array_search($recordingid, $recordingids);
|
||||||
|
|
||||||
$recording = new self(0, $recordings[$id], $metadata);
|
$recording = new self(0, $recordings[$id], $metadata);
|
||||||
$recording->raw_set('status', self::RECORDING_STATUS_PROCESSED);
|
$recording->set_status(self::RECORDING_STATUS_PROCESSED);
|
||||||
$recording->update();
|
|
||||||
$foundcount++;
|
$foundcount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ $definitions = [
|
||||||
'mod_bigbluebuttonbn/recordingchanged',
|
'mod_bigbluebuttonbn/recordingchanged',
|
||||||
'mod_bigbluebuttonbn/serversettingschanged',
|
'mod_bigbluebuttonbn/serversettingschanged',
|
||||||
],
|
],
|
||||||
'ttl' => HOURSECS,
|
'ttl' => 5 * MINSECS,
|
||||||
],
|
],
|
||||||
|
|
||||||
'currentfetch' => [
|
'currentfetch' => [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue