Skip to content

Commit 3d45f2a

Browse files
Implement disabledFeatures in create API (#152)
* Implement disabledFeatures in create API * Refactor * Implement disabled features exclude, update features enum * Add return type --------- Co-authored-by: Felix Jacobi <felix@jacobi-hamburg.net>
1 parent f1b66be commit 3d45f2a

5 files changed

Lines changed: 116 additions & 19 deletions

File tree

src/Enum/Feature.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/*
4+
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
5+
*
6+
* Copyright (c) 2016-2023 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 Feature extends Enum
29+
{
30+
public const BREAKOUT_ROOMS = 'breakoutRooms';
31+
public const CAPTIONS = 'captions';
32+
public const CHAT = 'chat';
33+
public const DOWNLOAD_PRESENTATION_WITH_ANNOTATIONS = 'downloadPresentationWithAnnotations';
34+
public const EXTERNAL_VIDEOS = 'externalVideos';
35+
public const IMPORT_PRESENTATION_WITHANNOTATIONS_FROM_BREAKOUTROOMS = 'importPresentationWithAnnotationsFromBreakoutRooms';
36+
public const IMPORT_SHARED_NOTES_FROM_BREAKOUTROOMS = 'importSharedNotesFromBreakoutRooms';
37+
public const LAYOUTS = 'layouts';
38+
public const LEARNING_DASHBOARD = 'learningDashboard';
39+
public const POLLS = 'polls';
40+
public const SCREENSHARE = 'screenshare';
41+
public const SHARED_NOTES = 'sharedNotes';
42+
public const VIRTUAL_BACKGROUNDS = 'virtualBackgrounds';
43+
public const CUSTOM_VIRTUAL_BACKGROUNDS = 'customVirtualBackgrounds';
44+
public const LIVE_TRANSCRIPTION = 'liveTranscription';
45+
public const PRESENTATION = 'presentation';
46+
}

src/Parameters/CreateMeetingParameters.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@
116116
* @method $this setVirtualBackgroundsDisabled(bool $isVirtualBackgroundsDisabled)
117117
* @method int getUserCameraCap()
118118
* @method $this setUserCameraCap(int $cap)
119+
* @method array getDisabledFeatures()
120+
* @method $this setDisabledFeatures(array $disabledFeatures)
121+
* @method array getDisabledFeaturesExclude()
122+
* @method $this setDisabledFeaturesExclude(array $disabledFeaturesExclude)
119123
*/
120124
class CreateMeetingParameters extends MetaParameters
121125
{
@@ -374,13 +378,25 @@ class CreateMeetingParameters extends MetaParameters
374378
*/
375379
private $breakoutRoomsGroups = [];
376380

381+
/**
382+
* @var array
383+
*/
384+
protected $disabledFeatures = [];
385+
386+
/**
387+
* @var array
388+
*/
389+
protected $disabledFeaturesExclude = [];
390+
377391
/**
378392
* @var array
379393
*/
380394
private $presentations = [];
381395

382396
public function __construct(string $meetingID, string $name)
383397
{
398+
$this->ignoreProperties = ['disabledFeatures', 'disabledFeaturesExclude'];
399+
384400
$this->meetingID = $meetingID;
385401
$this->name = $name;
386402
}
@@ -595,6 +611,20 @@ public function getHTTPQuery(): string
595611
{
596612
$queries = $this->getHTTPQueryArray();
597613

614+
// Add disabled features if any are set
615+
if (!empty($this->disabledFeatures)) {
616+
$queries = array_merge($queries, [
617+
'disabledFeatures' => implode(',', $this->disabledFeatures),
618+
]);
619+
}
620+
621+
// Add disabled features exclude if any are set
622+
if (!empty($this->disabledFeaturesExclude)) {
623+
$queries = array_merge($queries, [
624+
'disabledFeaturesExclude' => implode(',', $this->disabledFeaturesExclude),
625+
]);
626+
}
627+
598628
// Pre-defined groups to automatically assign the students to a given breakout room
599629
if (!empty($this->breakoutRoomsGroups)) {
600630
$queries = array_merge($queries, [

tests/TestCase.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
use BigBlueButton\Core\GuestPolicy;
2323
use BigBlueButton\Core\MeetingLayout;
24+
use BigBlueButton\Enum\Feature;
2425
use BigBlueButton\Parameters\CreateMeetingParameters;
2526
use BigBlueButton\Parameters\EndMeetingParameters;
2627
use BigBlueButton\Parameters\JoinMeetingParameters;
@@ -97,6 +98,8 @@ protected function generateCreateParams()
9798
'lockSettingsLockOnJoinConfigurable' => $this->faker->boolean(50),
9899
'allowModsToUnmuteUsers' => $this->faker->boolean(50),
99100
'allowModsToEjectCameras' => $this->faker->boolean(50),
101+
'disabledFeatures' => $this->faker->randomElements(Feature::getValues(), 3),
102+
'disabledFeaturesExclude' => $this->faker->randomElements(Feature::getValues(), 2),
100103
'meta_presenter' => $this->faker->name,
101104
'meta_endCallbackUrl' => $this->faker->url,
102105
'meta_bbb-recording-ready-url' => $this->faker->url,
@@ -206,7 +209,9 @@ protected function getCreateMock($params)
206209
->setBreakoutRoomsRecord($params['breakoutRoomsRecord'])
207210
->setAllowRequestsWithoutSession($params['allowRequestsWithoutSession'])
208211
->setVirtualBackgroundsDisabled($params['virtualBackgroundsDisabled'])
209-
->setUserCameraCap($params['userCameraCap']);
212+
->setUserCameraCap($params['userCameraCap'])
213+
->setDisabledFeatures($params['disabledFeatures'])
214+
->setDisabledFeaturesExclude($params['disabledFeaturesExclude']);
210215

211216
if (isset($params['moderatorPW'])) {
212217
$createMeetingParams->setModeratorPW($params['moderatorPW']);

tests/functional/AbstractBigBlueButtonFunctionalTest.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,8 @@ public function testCreateMeetingUrl(): void
106106
{
107107
$params = $this->generateCreateParams();
108108
$url = $this->bbb->getCreateMeetingUrl($this->getCreateMock($params));
109-
foreach ($params as $key => $value) {
110-
if (\is_bool($value)) {
111-
$value = $value ? 'true' : 'false';
112-
}
113-
$this->assertStringContainsString($key.'='.rawurlencode($value), $url);
114-
}
109+
110+
$this->assertUrlContainsAllRequestParameters($url, $params);
115111
}
116112

117113
/**
@@ -212,12 +208,7 @@ public function testCreateJoinMeetingUrl(): void
212208

213209
$url = $this->bbb->getJoinMeetingURL($joinMeetingMock);
214210

215-
foreach ($joinMeetingParams as $key => $value) {
216-
if (\is_bool($value)) {
217-
$value = $value ? 'true' : 'false';
218-
}
219-
$this->assertStringContainsString('='.rawurlencode($value), $url);
220-
}
211+
$this->assertUrlContainsAllRequestParameters($url, $joinMeetingParams);
221212
}
222213

223214
public function testJoinMeeting()
@@ -255,12 +246,8 @@ public function testCreateEndMeetingUrl(): void
255246
{
256247
$params = $this->generateEndMeetingParams();
257248
$url = $this->bbb->getEndMeetingURL($this->getEndMeetingMock($params));
258-
foreach ($params as $key => $value) {
259-
if (\is_bool($value)) {
260-
$value = $value ? 'true' : 'false';
261-
}
262-
$this->assertStringContainsString('='.rawurlencode($value), $url);
263-
}
249+
250+
$this->assertUrlContainsAllRequestParameters($url, $params);
264251
}
265252

266253
public function testEndMeeting()

tests/unit/Parameters/CreateMeetingParametersTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespace BigBlueButton\Parameters;
2121

2222
use BigBlueButton\Core\GuestPolicy;
23+
use BigBlueButton\Enum\Feature;
2324
use BigBlueButton\TestCase;
2425

2526
/**
@@ -90,6 +91,8 @@ public function testCreateMeetingParameters()
9091
$this->assertEquals($params['allowRequestsWithoutSession'], $createMeetingParams->isAllowRequestsWithoutSession());
9192
$this->assertEquals($params['virtualBackgroundsDisabled'], $createMeetingParams->isVirtualBackgroundsDisabled());
9293
$this->assertEquals(json_encode($params['groups']), json_encode($createMeetingParams->getBreakoutRoomsGroups()));
94+
$this->assertEquals($params['disabledFeatures'], $createMeetingParams->getDisabledFeatures());
95+
$this->assertEquals($params['disabledFeaturesExclude'], $createMeetingParams->getDisabledFeaturesExclude());
9396

9497
// Check values are empty of this is not a breakout room
9598
$this->assertNull($createMeetingParams->isBreakout());
@@ -104,6 +107,32 @@ public function testCreateMeetingParameters()
104107
$this->assertEquals($newId, $createMeetingParams->getMeetingID());
105108
}
106109

110+
public function testDisabledFeatures(): void
111+
{
112+
$params = $this->generateCreateParams();
113+
$createMeetingParams = $this->getCreateMock($params);
114+
115+
// Test empty disabled features
116+
$createMeetingParams->setDisabledFeatures([]);
117+
$params = urldecode($createMeetingParams->getHTTPQuery());
118+
$this->assertStringNotContainsString('disabledFeatures=', $params);
119+
120+
// Test with multiple disabled features
121+
$createMeetingParams->setDisabledFeatures([Feature::CHAT, Feature::POLLS, Feature::CAPTIONS]);
122+
$params = urldecode($createMeetingParams->getHTTPQuery());
123+
$this->assertStringContainsString('disabledFeatures=chat,polls,captions', $params);
124+
125+
// Test empty disabled features exclude
126+
$createMeetingParams->setDisabledFeaturesExclude([]);
127+
$params = urldecode($createMeetingParams->getHTTPQuery());
128+
$this->assertStringNotContainsString('disabledFeaturesExclude=', $params);
129+
130+
// Test with multiple disabled features exclude
131+
$createMeetingParams->setDisabledFeaturesExclude([Feature::CHAT, Feature::POLLS]);
132+
$params = urldecode($createMeetingParams->getHTTPQuery());
133+
$this->assertStringContainsString('disabledFeaturesExclude=chat,polls', $params);
134+
}
135+
107136
public function testCreateBreakoutMeeting()
108137
{
109138
$params = $this->generateBreakoutCreateParams($this->generateCreateParams());

0 commit comments

Comments
 (0)