Skip to content

Commit 9c8f3b7

Browse files
authored
Implement API changes in BBB 2.4-2.6 (#156)
* Implement API changes in BBB 2.4-2.6 * Add backwards compatibility for the old method setLockSettingsDisableNote and isLockSettingsDisableNote * Fix CS and composer scripts * CS Fixer * Adjust tests * Add errorRedirectUrl join parameter * Add final to test classes
1 parent 3d45f2a commit 9c8f3b7

42 files changed

Lines changed: 266 additions & 80 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@
103103
"test-functional": "tools/phpunit --testsuite=\"BigBlueButton functional test suite\" --exclude-group=functional-legacy",
104104
"cs-fix": "tools/php-cs-fixer fix --allow-risky=yes",
105105
"cs-test": "tools/php-cs-fixer fix --dry-run --allow-risky=yes",
106-
"psalm": "psalm --threads=1",
107-
"psalm-clear": "psalm --clear-cache && psalm --clear-global-cache",
108-
"psalm-fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
106+
"psalm": "tools/psalm --threads=1",
107+
"psalm-clear": "tools/psalm --clear-cache && psalm --clear-global-cache",
108+
"psalm-fix": "tools/psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
109109
"post-install-cmd": "tools/composer-git-hooks add --ignore-lock",
110110
"post-update-cmd": "tools/composer-git-hooks update"
111111
},

src/BigBlueButton.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class BigBlueButton
113113
*
114114
* @throws ConfigException
115115
*/
116-
public function __construct(string $baseUrl = null, string $secret = null, TransportInterface $transport = null, string $hashingAlgorithm = HashingAlgorithm::SHA_1)
116+
public function __construct(?string $baseUrl = null, ?string $secret = null, ?TransportInterface $transport = null, string $hashingAlgorithm = HashingAlgorithm::SHA_1)
117117
{
118118
// Keeping backward compatibility with older deployed versions
119119
$this->securitySecret = $secret ?: getenv('BBB_SECURITY_SALT') ?: getenv('BBB_SECRET');

src/Core/Meeting.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
namespace BigBlueButton\Core;
2222

23+
use BigBlueButton\Enum\Role;
24+
2325
/**
2426
* Class Meeting.
2527
*/
@@ -324,7 +326,7 @@ public function getModerators(): array
324326
$attendees = $this->getAttendees();
325327

326328
$moderators = array_filter($attendees, function ($attendee) {
327-
return $attendee->getRole() === 'MODERATOR';
329+
return $attendee->getRole() === Role::MODERATOR;
328330
});
329331

330332
return array_values($moderators);
@@ -340,7 +342,7 @@ public function getViewers(): array
340342
$attendees = $this->getAttendees();
341343

342344
$viewers = array_filter($attendees, function ($attendee) {
343-
return $attendee->getRole() === 'VIEWER';
345+
return $attendee->getRole() === Role::VIEWER;
344346
});
345347

346348
return array_values($viewers);

src/Enum/Role.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5+
*
6+
* Copyright (c) 2016-2022 BigBlueButton Inc. and by respective authors (see below).
7+
*
8+
* This program is free software; you can redistribute it and/or modify it under the
9+
* terms of the GNU Lesser General Public License as published by the Free Software
10+
* Foundation; either version 3.0 of the License, or (at your option) any later
11+
* version.
12+
*
13+
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
14+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15+
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License along
18+
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
namespace BigBlueButton\Enum;
22+
23+
use MabeEnum\Enum;
24+
25+
/**
26+
* @psalm-immutable
27+
*/
28+
class Role extends Enum
29+
{
30+
public const MODERATOR = 'MODERATOR';
31+
public const VIEWER = 'VIEWER';
32+
}

src/Parameters/CreateMeetingParameters.php

Lines changed: 128 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
* @method $this setSequence(int $sequence)
4949
* @method bool|null isFreeJoin()
5050
* @method $this setFreeJoin(bool $isFreeJoin)
51-
* @method bool|null isBreakoutRoomsEnabled()
52-
* @method $this setBreakoutRoomsEnabled(bool $isBreakoutRoomsEnabled)
5351
* @method bool|null isBreakoutRoomsPrivateChatEnabled()
5452
* @method $this setBreakoutRoomsPrivateChatEnabled(bool $isBreakoutRoomsPrivateChatEnabled)
5553
* @method bool|null isBreakoutRoomsRecord()
@@ -82,8 +80,8 @@
8280
* @method $this setLockSettingsDisablePrivateChat(bool $isLockSettingsDisablePrivateChat)
8381
* @method bool|null isLockSettingsDisablePublicChat()
8482
* @method $this setLockSettingsDisablePublicChat(bool $isLockSettingsDisablePublicChat)
85-
* @method bool|null isLockSettingsDisableNote()
86-
* @method $this setLockSettingsDisableNote(bool $isLockSettingsDisableNote)
83+
* @method bool|null isLockSettingsDisableNotes()
84+
* @method $this setLockSettingsDisableNotes(bool $isLockSettingsDisableNotes)
8785
* @method bool|null isLockSettingsLockedLayout()
8886
* @method $this setLockSettingsLockedLayout(bool $isLockSettingsLockedLayout)
8987
* @method bool|null isLockSettingsHideUserList()
@@ -104,16 +102,12 @@
104102
* @method $this setMeetingLayout(string $meetingLayout)
105103
* @method string getMeetingEndedURL()
106104
* @method $this setMeetingEndedURL(string $meetingEndedURL)
107-
* @method bool|null isLearningDashboardEnabled()
108-
* @method $this setLearningDashboardEnabled(bool $isLearningDashboardEnabled)
109105
* @method int getLearningDashboardCleanupDelayInMinutes()
110106
* @method $this setLearningDashboardCleanupDelayInMinutes(int $learningDashboardCleanupDelayInMinutes)
111107
* @method bool|null isAllowModsToEjectCameras()
112108
* @method $this setAllowModsToEjectCameras(bool $isAllowModsToEjectCameras)
113109
* @method bool|null isAllowRequestsWithoutSession()
114110
* @method $this setAllowRequestsWithoutSession(bool $isAllowRequestsWithoutSession)
115-
* @method bool|null isVirtualBackgroundsDisabled()
116-
* @method $this setVirtualBackgroundsDisabled(bool $isVirtualBackgroundsDisabled)
117111
* @method int getUserCameraCap()
118112
* @method $this setUserCameraCap(int $cap)
119113
* @method array getDisabledFeatures()
@@ -291,7 +285,7 @@ class CreateMeetingParameters extends MetaParameters
291285
/**
292286
* @var bool
293287
*/
294-
protected $lockSettingsDisableNote;
288+
protected $lockSettingsDisableNotes;
295289

296290
/**
297291
* @var bool
@@ -313,6 +307,11 @@ class CreateMeetingParameters extends MetaParameters
313307
*/
314308
protected $lockSettingsLockOnJoinConfigurable;
315309

310+
/**
311+
* @var bool
312+
*/
313+
protected $lockSettingsHideViewersCursor;
314+
316315
/**
317316
* @var string
318317
*/
@@ -388,6 +387,51 @@ class CreateMeetingParameters extends MetaParameters
388387
*/
389388
protected $disabledFeaturesExclude = [];
390389

390+
/**
391+
* @var int
392+
*/
393+
protected $meetingCameraCap;
394+
395+
/**
396+
* @var int
397+
*/
398+
protected $meetingExpireIfNoUserJoinedInMinutes;
399+
400+
/**
401+
* @var int
402+
*/
403+
protected $meetingExpireWhenLastUserLeftInMinutes;
404+
405+
/**
406+
* @var bool
407+
*/
408+
protected $preUploadedPresentationOverrideDefault;
409+
410+
/**
411+
* @var bool
412+
*/
413+
protected $notifyRecordingIsOn;
414+
415+
/**
416+
* @var bool
417+
*/
418+
protected $remindRecordingIsOn;
419+
420+
/**
421+
* @var bool
422+
*/
423+
protected $recordFullDurationMedia;
424+
425+
/**
426+
* @var string
427+
*/
428+
protected $presentationUploadExternalUrl;
429+
430+
/**
431+
* @var string
432+
*/
433+
protected $presentationUploadExternalDescription;
434+
391435
/**
392436
* @var array
393437
*/
@@ -427,6 +471,80 @@ public function isBreakout(): ?bool
427471
return $this->isBreakout;
428472
}
429473

474+
/**
475+
* @deprecated use disabledFeatures instead
476+
* Backwards compatibility for the old method name with the missing 's' at the end
477+
*/
478+
public function setLockSettingsDisableNote(bool $isLockSettingsDisableNote): self
479+
{
480+
$this->isLockSettingsDisableNotes = $isLockSettingsDisableNote;
481+
482+
return $this;
483+
}
484+
485+
/**
486+
* @deprecated use disabledFeatures instead
487+
* Backwards compatibility for the old method name with the missing 's' at the end
488+
*/
489+
public function isLockSettingsDisableNote(): bool
490+
{
491+
return $this->isLockSettingsDisableNotes;
492+
}
493+
494+
/**
495+
* @deprecated Use disabledFeatures instead
496+
*/
497+
public function setLearningDashboardEnabled(bool $learningDashboardEnabled): self
498+
{
499+
$this->learningDashboardEnabled = $learningDashboardEnabled;
500+
501+
return $this;
502+
}
503+
504+
/**
505+
* @deprecated Use disabledFeatures instead
506+
*/
507+
public function isLearningDashboardEnabled(): bool
508+
{
509+
return $this->learningDashboardEnabled;
510+
}
511+
512+
/**
513+
* @deprecated Use disabledFeatures instead
514+
*/
515+
public function setVirtualBackgroundsDisabled(bool $virtualBackgroundsDisabled): self
516+
{
517+
$this->virtualBackgroundsDisabled = $virtualBackgroundsDisabled;
518+
519+
return $this;
520+
}
521+
522+
/**
523+
* @deprecated Use disabledFeatures instead
524+
*/
525+
public function isVirtualBackgroundsDisabled(): bool
526+
{
527+
return $this->virtualBackgroundsDisabled;
528+
}
529+
530+
/**
531+
* @deprecated Use disabledFeatures instead
532+
*/
533+
public function setBreakoutRoomsEnabled(bool $breakoutRoomsEnabled): self
534+
{
535+
$this->breakoutRoomsEnabled = $breakoutRoomsEnabled;
536+
537+
return $this;
538+
}
539+
540+
/**
541+
* @deprecated Use disabledFeatures instead
542+
*/
543+
public function isBreakoutRoomsEnabled(): bool
544+
{
545+
return $this->breakoutRoomsEnabled;
546+
}
547+
430548
public function isUserCameraCapDisabled(): bool
431549
{
432550
return $this->userCameraCap === 0;
@@ -493,7 +611,7 @@ public function setGuestPolicyAlwaysAccept(): self
493611
return $this;
494612
}
495613

496-
public function addPresentation(string $nameOrUrl, string $content = null, string $filename = null): self
614+
public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null): self
497615
{
498616
if (!$filename) {
499617
$this->presentations[$nameOrUrl] = !$content ?: base64_encode($content);

src/Parameters/EndMeetingParameters.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class EndMeetingParameters extends BaseParameters
3737
*/
3838
protected $password;
3939

40-
public function __construct(string $meetingID, string $password = null)
40+
public function __construct(string $meetingID, ?string $password = null)
4141
{
4242
if (\func_num_args() === 2) {
4343
@trigger_error(sprintf('Passing $password parameter to constructor of "%s" is deprecated since 5.1 and will be removed in 6.0. Recent BigBlueButton versions does not require the password parameter to end a meeting.', self::class), \E_USER_DEPRECATED);

src/Parameters/InsertDocumentParameters.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(string $meetingID)
4242
$this->meetingID = $meetingID;
4343
}
4444

45-
public function addPresentation(string $url, string $filename, bool $downloadable = null, bool $removable = null): self
45+
public function addPresentation(string $url, string $filename, ?bool $downloadable = null, ?bool $removable = null): self
4646
{
4747
$this->presentations[$url] = [
4848
'filename' => $filename,

src/Parameters/JoinMeetingParameters.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
namespace BigBlueButton\Parameters;
2121

22+
use BigBlueButton\Enum\Role;
23+
2224
/**
2325
* Class JoinMeetingParametersTest.
2426
*
@@ -38,6 +40,8 @@
3840
* @method $this setAvatarURL(string $avatarURL)
3941
* @method bool|null isRedirect()
4042
* @method $this setRedirect(bool $redirect)
43+
* @method string getErrorRedirectUrl()
44+
* @method $this setErrorRedirectUrl(string $errorRedirectUrl)
4145
* @method string getClientURL()
4246
* @method $this setClientURL(string $clientURL)
4347
* @method bool|null isGuest()
@@ -102,6 +106,11 @@ class JoinMeetingParameters extends UserDataParameters
102106
*/
103107
protected $redirect;
104108

109+
/**
110+
* @var string
111+
*/
112+
protected $errorRedirectUrl;
113+
105114
/**
106115
* @var string
107116
*/
@@ -122,15 +131,20 @@ class JoinMeetingParameters extends UserDataParameters
122131
*/
123132
protected $excludeFromDashboard;
124133

125-
public function __construct(string $meetingID, string $fullName, string $password = null)
134+
public function __construct(string $meetingID, string $fullName, $passwordOrRole)
126135
{
127-
if (\func_num_args() === 3) {
128-
@trigger_error(sprintf('Passing $password parameter to constructor of "%s" is deprecated since 5.1 and will be removed in 6.0. Use "%s::setRole()" to set the designated role for the joining user instead.', self::class, self::class), \E_USER_DEPRECATED);
136+
if (!$passwordOrRole instanceof Role) {
137+
@trigger_error(sprintf('Passing a password as the third parameter to constructor of "%s" is deprecated since 5.1 and will be removed in 6.0. Pass the role for the joining user instead.', self::class, self::class), \E_USER_DEPRECATED);
129138
}
130139

131140
$this->meetingID = $meetingID;
132141
$this->fullName = $fullName;
133-
$this->password = $password;
142+
143+
if (Role::MODERATOR === $passwordOrRole || Role::VIEWER === $passwordOrRole) {
144+
$this->role = $passwordOrRole;
145+
} else {
146+
$this->password = $passwordOrRole;
147+
}
134148
}
135149

136150
/**

tests/TestCase.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use BigBlueButton\Core\GuestPolicy;
2323
use BigBlueButton\Core\MeetingLayout;
2424
use BigBlueButton\Enum\Feature;
25+
use BigBlueButton\Enum\Role;
2526
use BigBlueButton\Parameters\CreateMeetingParameters;
2627
use BigBlueButton\Parameters\EndMeetingParameters;
2728
use BigBlueButton\Parameters\JoinMeetingParameters;
@@ -246,11 +247,12 @@ protected function generateJoinMeetingParams()
246247
{
247248
return ['meetingID' => $this->faker->uuid,
248249
'fullName' => $this->faker->name,
249-
'password' => $this->faker->password,
250+
'role' => $this->faker->randomElement(Role::getValues()),
250251
'userID' => $this->faker->numberBetween(1, 1000),
251252
'webVoiceConf' => $this->faker->word,
252253
'createTime' => $this->faker->unixTime,
253254
'configToken' => $this->faker->word,
255+
'errorRedirectUrl' => $this->faker->url,
254256
'userdata-countrycode' => $this->faker->countryCode,
255257
'userdata-email' => $this->faker->email,
256258
'userdata-commercial' => false,
@@ -264,16 +266,13 @@ protected function generateJoinMeetingParams()
264266
*/
265267
protected function getJoinMeetingMock($params)
266268
{
267-
if (isset($params['password'])) {
268-
$joinMeetingParams = new JoinMeetingParameters($params['meetingID'], $params['fullName'], $params['password']);
269-
} else {
270-
$joinMeetingParams = new JoinMeetingParameters($params['meetingID'], $params['fullName']);
271-
}
269+
$joinMeetingParams = new JoinMeetingParameters($params['meetingID'], $params['fullName'], $params['role']);
272270

273271
return $joinMeetingParams
274272
->setUserID($params['userID'])
275273
->setWebVoiceConf($params['webVoiceConf'])
276274
->setCreateTime($params['createTime'])
275+
->setErrorRedirectUrl($params['errorRedirectUrl'])
277276
->setConfigToken($params['configToken'])
278277
->addUserData('countrycode', $params['userdata-countrycode'])
279278
->addUserData('email', $params['userdata-email'])

0 commit comments

Comments
 (0)