Skip to content

Commit

Permalink
Implement disabledFeatures in create API
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelWei committed Aug 30, 2023
1 parent 6aff919 commit 9dbd87e
Show file tree
Hide file tree
Showing 22 changed files with 92 additions and 64 deletions.
2 changes: 2 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
'yoda_style' => false,
'single_line_throw' => false,
'increment_style' => false,
'modernize_strpos' => false,
'get_class_to_class_keyword' => false,
])
->setRiskyAllowed(true)
->setFinder($finder);
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"ext-curl": "*",
"ext-simplexml": "*",
"ext-mbstring": "*",
"ext-json": "*"
"ext-json": "*",
"marc-mabe/php-enum": "^4.7"
},
"suggest": {
"psr/http-client-implementation": "To use the PsrHttpClientTransport.",
Expand Down
7 changes: 3 additions & 4 deletions src/BigBlueButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
use BigBlueButton\Responses\PutRecordingTextTrackResponse;
use BigBlueButton\Responses\UpdateRecordingsResponse;
use BigBlueButton\Util\UrlBuilder;
use SimpleXMLElement;

/**
* Class BigBlueButton.
Expand Down Expand Up @@ -108,7 +107,7 @@ class BigBlueButton
*
* @throws ConfigException
*/
public function __construct(?string $baseUrl = null, ?string $secret = null, ?TransportInterface $transport = null)
public function __construct(string $baseUrl = null, string $secret = null, TransportInterface $transport = null)
{
// Keeping backward compatibility with older deployed versions
$this->securitySecret = $secret ?: getenv('BBB_SECURITY_SALT') ?: getenv('BBB_SECRET');
Expand Down Expand Up @@ -478,10 +477,10 @@ public function setJSessionId(string $jSessionId): void
* @throws ParsingException
* @throws RuntimeException
*/
private function processXmlResponse(string $url, string $payload = '', string $contentType = 'application/xml'): SimpleXMLElement
private function processXmlResponse(string $url, string $payload = '', string $contentType = 'application/xml'): \SimpleXMLElement
{
try {
return new SimpleXMLElement($this->requestUrl($url, $payload, $contentType));
return new \SimpleXMLElement($this->requestUrl($url, $payload, $contentType));
} catch (NetworkException|RuntimeException $e) {
throw $e;
} catch (\Throwable $e) {
Expand Down
39 changes: 39 additions & 0 deletions src/Enum/Feature.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/*
* BigBlueButton open source conferencing system - https://www.bigbluebutton.org/.
*
* Copyright (c) 2016-2023 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*/

namespace BigBlueButton\Enum;

use MabeEnum\Enum;

class Feature extends Enum
{
public const BREAKOUT_ROOMS = 'breakoutRooms';
public const CAPTIONS = 'captions';
public const CHAT = 'chat';
public const EXTERNAL_VIDEOS = 'externalVideos';
public const LAYOUTS = 'layouts';
public const LEARNING_DASHBOARD = 'learningDashboard';
public const POLLS = 'polls';
public const SCREENSHARE = 'screenshare';
public const SHARED_NOTES = 'sharedNotes';
public const VIRTUAL_BACKGROUNDS = 'virtualBackgrounds';
public const LIVE_TRANSCRIPTION = 'liveTranscription';
public const PRESENTATION = 'presentation';
}
4 changes: 1 addition & 3 deletions src/Exceptions/BaseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@

namespace BigBlueButton\Exceptions;

use Exception;

/**
* @abstract since 4.0.
*/
class BaseException extends Exception
class BaseException extends \Exception
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ public function __construct(
$this->defaultHeaders = $defaultHeaders;
}

/**
* {@inheritDoc}
*/
public function request(TransportRequest $request): TransportResponse
{
if ('' !== $payload = $request->getPayload()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ public static function create(array $defaultHeaders = [], array $defaultOptions
// @codeCoverageIgnoreEnd
}

/**
* {@inheritDoc}
*/
public function request(TransportRequest $request): TransportResponse
{
$headers = $this->defaultHeaders;
Expand Down
3 changes: 0 additions & 3 deletions src/Http/Transport/CurlTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ public static function createWithDefaultOptions(array $additionalCurlOptions = [
// @codeCoverageIgnoreEnd
}

/**
* {@inheritDoc}
*/
public function request(TransportRequest $request): TransportResponse
{
// @codeCoverageIgnoreStart
Expand Down
3 changes: 0 additions & 3 deletions src/Parameters/BaseParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ public function __call(string $name, array $arguments)
return null;
}

/**
* @return mixed
*/
protected function getter(string $name)
{
if (property_exists($this, $name)) {
Expand Down
18 changes: 14 additions & 4 deletions src/Parameters/CreateMeetingParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
* @method $this setVirtualBackgroundsDisabled(bool $isVirtualBackgroundsDisabled)
* @method int getUserCameraCap()
* @method $this setUserCameraCap(int $cap)
* @method array getDisabledFeatures()
* @method $this setDisabledFeatures(array $disabledFeatures)
*/
class CreateMeetingParameters extends MetaParameters
{
Expand Down Expand Up @@ -373,13 +375,20 @@ class CreateMeetingParameters extends MetaParameters
*/
protected $userCameraCap;

/**
* @var array
*/
protected $disabledFeatures = [];

/**
* @var array
*/
private $presentations = [];

public function __construct(string $meetingID, string $name)
{
$this->ignoreProperties = ['disabledFeatures'];

$this->meetingID = $meetingID;
$this->name = $name;
}
Expand Down Expand Up @@ -476,7 +485,7 @@ public function setGuestPolicyAlwaysAccept(): self
return $this;
}

public function addPresentation(string $nameOrUrl, ?string $content = null, ?string $filename = null): self
public function addPresentation(string $nameOrUrl, string $content = null, string $filename = null): self
{
if (!$filename) {
$this->presentations[$nameOrUrl] = !$content ?: base64_encode($content);
Expand All @@ -492,9 +501,6 @@ public function getPresentations(): array
return $this->presentations;
}

/**
* @return mixed
*/
public function getPresentationsAsXML()
{
$result = '';
Expand Down Expand Up @@ -527,6 +533,10 @@ public function getHTTPQuery(): string
{
$queries = $this->getHTTPQueryArray();

if (\count($this->getDisabledFeatures()) != 0) {
$queries['disabledFeatures'] = implode(',', $this->getDisabledFeatures());
}

if ($this->isBreakout()) {
if ($this->parentMeetingID === null || $this->sequence === null) {
trigger_error('Breakout rooms require a parentMeetingID and sequence number.', \E_USER_WARNING);
Expand Down
5 changes: 1 addition & 4 deletions src/Parameters/InsertDocumentParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(string $meetingID)
$this->meetingID = $meetingID;
}

public function addPresentation(string $url, string $filename, ?bool $downloadable = null, ?bool $removable = null): self
public function addPresentation(string $url, string $filename, bool $downloadable = null, bool $removable = null): self
{
$this->presentations[$url] = [
'filename' => $filename,
Expand All @@ -60,9 +60,6 @@ public function removePresentation(string $url): self
return $this;
}

/**
* @return mixed
*/
public function getPresentationsAsXML()
{
$result = '';
Expand Down
5 changes: 0 additions & 5 deletions src/Parameters/PutRecordingTextTrackParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,10 @@ class PutRecordingTextTrackParameters extends BaseParameters
*/
protected $contentType;

/**
* @var mixed
*/
protected $file;

/**
* GetRecordingTextTracksParameters constructor.
*
* @param $recordID
*/
public function __construct(string $recordID, string $kind, string $lang, string $label)
{
Expand Down
3 changes: 0 additions & 3 deletions src/Responses/BaseResponseAsJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ abstract class BaseResponseAsJson
public const FAILED = 'FAILED';
public const CHECKSUM_ERROR = 'checksumError';

/**
* @var mixed
*/
protected $data;

/**
Expand Down
12 changes: 4 additions & 8 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use BigBlueButton\Core\GuestPolicy;
use BigBlueButton\Core\MeetingLayout;
use BigBlueButton\Enum\Feature;
use BigBlueButton\Parameters\CreateMeetingParameters;
use BigBlueButton\Parameters\EndMeetingParameters;
use BigBlueButton\Parameters\JoinMeetingParameters;
Expand All @@ -40,9 +41,6 @@ class TestCase extends \PHPUnit\Framework\TestCase
*/
protected $faker;

/**
* {@inheritdoc}
*/
protected function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -100,6 +98,7 @@ protected function generateCreateParams()
'lockSettingsLockOnJoinConfigurable' => $this->faker->boolean(50),
'allowModsToUnmuteUsers' => $this->faker->boolean(50),
'allowModsToEjectCameras' => $this->faker->boolean(50),
'disabledFeatures' => $this->faker->randomElements(Feature::getValues(), 3),
'meta_presenter' => $this->faker->name,
'meta_endCallbackUrl' => $this->faker->url,
'meta_bbb-recording-ready-url' => $this->faker->url,
Expand Down Expand Up @@ -127,8 +126,6 @@ protected function generateCreateParams()
}

/**
* @param $createParams
*
* @return array
*/
protected function generateBreakoutCreateParams($createParams)
Expand Down Expand Up @@ -198,12 +195,11 @@ protected function getCreateMock($params)
->setBreakoutRoomsRecord($params['breakoutRoomsRecord'])
->setAllowRequestsWithoutSession($params['allowRequestsWithoutSession'])
->setVirtualBackgroundsDisabled($params['virtualBackgroundsDisabled'])
->setUserCameraCap($params['userCameraCap']);
->setUserCameraCap($params['userCameraCap'])
->setDisabledFeatures($params['disabledFeatures']);
}

/**
* @param $params
*
* @return CreateMeetingParameters
*/
protected function getBreakoutCreateMock($params)
Expand Down
3 changes: 0 additions & 3 deletions tests/functional/BigBlueButtonWithCurlTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@

final class BigBlueButtonWithCurlTransportTest extends AbstractBigBlueButtonFunctionalTest
{
/**
* {@inheritDoc}
*/
protected static function createTransport(): TransportInterface
{
return CurlTransport::createWithDefaultOptions();
Expand Down
3 changes: 0 additions & 3 deletions tests/functional/BigBlueButtonWithPsrHttpClientTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@

final class BigBlueButtonWithPsrHttpClientTransport extends AbstractBigBlueButtonFunctionalTest
{
/**
* {@inheritDoc}
*/
protected static function createTransport(): TransportInterface
{
$psr17Factory = new Psr17Factory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@

final class BigBlueButtonWithSymfonyHttpClientTransportTest extends AbstractBigBlueButtonFunctionalTest
{
/**
* {@inheritDoc}
*/
protected static function createTransport(): TransportInterface
{
return SymfonyHttpClientTransport::create();
Expand Down
9 changes: 3 additions & 6 deletions tests/integration/Http/Transport/CurlTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
*/
final class CurlTransportTest extends TestCase
{
/**
* {@inheritDoc}
*/
public static function setUpBeforeClass(): void
{
TestHttpServer::start();
Expand All @@ -45,9 +42,9 @@ public static function setUpBeforeClass(): void
public function provideBadResponseCodes(): iterable
{
// cURL does not understand codes below 200 properly.
// foreach (range(100, 199) as $badCode) {
// yield 'HTTP code ' . $badCode => [$badCode];
// }
// foreach (range(100, 199) as $badCode) {
// yield 'HTTP code ' . $badCode => [$badCode];
// }

foreach (range(300, 599) as $badCode) {
yield 'HTTP code '.$badCode => [$badCode];
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/BigBlueButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ public function testCreateMeetingUrl()
if (\is_bool($value)) {
$value = $value ? 'true' : 'false';
}

if ($key == 'disabledFeatures') {
$value = implode(',', $value);
}

$this->assertStringContainsString(rawurlencode($key).'='.rawurlencode($value), $url);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ final class PsrHttpClientTransportTest extends TestCase
*/
private $streamFactoryMock;

/**
* {@inheritDoc}
*/
protected function setUp(): void
{
$this->transport = $this->createTransport();
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/Http/Transport/HeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ public function provideNonStringHeaders(): iterable

/**
* @dataProvider provideNonStringHeaders
*
* @param mixed $badHeader
*/
public function testMergeCurlHeadersWithNonStringHeaders($badHeader): void
{
Expand Down
Loading

0 comments on commit 9dbd87e

Please sign in to comment.