Skip to content

Commit 2e4d3eb

Browse files
authored
webservice: use self-documenting boolean
Because paid_user_limit_reached is a little expensive, it caches the user list, so calling the function multiple times won't result in a different answer, only additional overhead.
1 parent ffd67cf commit 2e4d3eb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

classes/webservice.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,18 +807,20 @@ public function provide_license($zoomuserid) {
807807
// Classic: user:read:admin.
808808
// Granular: user:read:user:admin.
809809
if ($this->recyclelicenses && $this->make_call("users/$zoomuserid")->type == ZOOM_USER_TYPE_BASIC) {
810-
if ($this->paid_user_limit_reached()) {
810+
$licenseisavailable = !$this->paid_user_limit_reached();
811+
if (!$licenseisavailable) {
811812
$leastrecentlyactivepaiduserid = $this->get_least_recently_active_paid_user_id();
812813
// Changes least_recently_active_user to a basic user so we can use their license.
813814
if ($leastrecentlyactivepaiduserid) {
814815
$this->make_call("users/$leastrecentlyactivepaiduserid", ['type' => ZOOM_USER_TYPE_BASIC], 'patch');
816+
$licenseisavailable = true;
815817
}
816818
}
817819

818820
// Changes current user to pro so they can make a meeting.
819821
// Classic: user:write:admin.
820822
// Granular: user:update:user:admin.
821-
if (!$this->paid_user_limit_reached() || $leastrecentlyactivepaiduserid) {
823+
if ($licenseisavailable) {
822824
$this->make_call("users/$zoomuserid", ['type' => ZOOM_USER_TYPE_PRO], 'patch');
823825
}
824826
}

0 commit comments

Comments
 (0)