Skip to content

Commit 19a815c

Browse files
committed
Add check if there is no user to borrow license from
1 parent 6ae7dda commit 19a815c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

classes/webservice.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,12 @@ public function provide_license($zoomuserid) {
810810
if ($this->paid_user_limit_reached()) {
811811
$leastrecentlyactivepaiduserid = $this->get_least_recently_active_paid_user_id();
812812
// Changes least_recently_active_user to a basic user so we can use their license.
813-
$this->make_call("users/$leastrecentlyactivepaiduserid", ['type' => ZOOM_USER_TYPE_BASIC], 'patch');
813+
if ($leastrecentlyactivepaiduserid) {
814+
$this->make_call("users/$leastrecentlyactivepaiduserid", ['type' => ZOOM_USER_TYPE_BASIC], 'patch');
815+
}
816+
else {
817+
throw new moodle_exception('errornousersfound', 'mod_zoom');
818+
}
814819
}
815820

816821
// Changes current user to pro so they can make a meeting.

lang/en/zoom.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
$string['err_start_time_past_recurring'] = 'For recurring meetings, the date portion of this field is the earliest possible date for the next meeting. This date must be today or in the future.';
132132
$string['err_weekly_days'] = 'Select day(s) for the recurring weekly meeting';
133133
$string['erroraddinstance'] = 'Could not create new zoom meeting. Invalid options selected for a recurring meeting.';
134+
$string['errornousersfound'] = 'There is no user to borrow license from.';
134135
$string['errorwebservice'] = 'Zoom webservice error: {$a}.';
135136
$string['errorwebservice_badrequest'] = 'Zoom received a bad request: {$a}';
136137
$string['errorwebservice_notfound'] = 'The resource does not exists';

0 commit comments

Comments
 (0)