Skip to content

Commit a08e669

Browse files
committed
webservice: get_recording_url_list error handling
We need get_recording_url_list() to return an array of recordings. So when the API gives us an error message that means "there are no recordings", then we need to return an empty array (so that it matches). If the API gives us an error message that means "there was a problem when we tried to find the recordings", then we don't want to pretend that we know how many recordings there are (so we allow other exception types to bubble up). Finally, if there was no API error message, then we should have an API response that we can use. However, the code is written to assume that we know how the API response is structured. If the code is in the structure that we expect, then use it. Otherwise, we should throw our own "unexpected response structure" error message to avoid returning incorrect information.
1 parent ac668a7 commit a08e669

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

classes/webservice.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,9 +1135,22 @@ public function get_recording_url_list($meetingid) {
11351135
// Classic: recording:read:admin.
11361136
// Granular: cloud_recording:read:list_recording_files:admin.
11371137
$url = 'meetings/' . $this->encode_uuid($meetingid) . '/recordings';
1138-
$response = $this->make_call($url);
11391138

1140-
if (!empty($response->recording_files)) {
1139+
try {
1140+
$response = $this->make_call($url);
1141+
} catch (not_found_exception $e) {
1142+
// If the meeting was not found (1001) or there are no recordings (3301), return an empty array.
1143+
return [];
1144+
}
1145+
1146+
if (empty($response->recording_files)) {
1147+
$recordingcount = (int) $response->recording_count;
1148+
$audiocount = count($response->participant_audio_files);
1149+
if ($recordingcount !== $audiocount) {
1150+
// If there are no recording files and the recording count does not match, throw an exception.
1151+
throw new bad_request_exception("recording_count: $recordingcount != participant_audio_files: $audiocount", 400);
1152+
}
1153+
} else {
11411154
foreach ($response->recording_files as $recording) {
11421155
$url = $recording->play_url ?? $recording->download_url ?? null;
11431156
if (!empty($url) && isset($allowedrecordingtypes[$recording->file_type])) {

0 commit comments

Comments
 (0)