Skip to content

Commit

Permalink
Merge pull request #832 from hanazarraa/audio-preset-group
Browse files Browse the repository at this point in the history
  • Loading branch information
GhaziTriki authored Jul 24, 2023
2 parents 8ddbbde + 93bfbad commit 0b53cf9
Show file tree
Hide file tree
Showing 12 changed files with 235 additions and 209 deletions.
2 changes: 2 additions & 0 deletions bbbeasy-backend/app/src/Actions/Core/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ public function execute($f3, $params): void

// add configured presets
$presets = $form['presetsConfig'];

if ($presets) {
$presetSettings = new PresetSetting();
$result = $presetSettings->savePresetSettings($presets);

if ('string' === \gettype($result)) {
$this->renderJson(['errors' => $result], ResponseCode::HTTP_INTERNAL_SERVER_ERROR);
}
Expand Down
6 changes: 4 additions & 2 deletions bbbeasy-backend/app/src/Actions/Rooms/Start.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,14 @@ public function createMeeting(string $meetingId, BigBlueButtonRequester $bbbRequ
$createParams->setAttendeePassword(DataUtils::generateRandomString());
// @todo : set later via presets

$createParams->setModeratorOnlyMessage('to invite someone you can use this link http://bbbeasy.test:3300/bbbeasy/' . $link);
$createParams->setModeratorOnlyMessage('to invite someone you can use this link http://bbbeasy.test/r/' . $link);

// @fixme: delete after fixing the PHP library
$createParams->setAllowRequestsWithoutSession(true);

$this->logger->info('Received request to create a new meeting.', ['meetingID' => $meetingId]);
$createMeetingResponse = $bbbRequester->createMeeting($createParams);

if ($createMeetingResponse->failed()) {
$this->logger->warning('Meeting could not be created.');
$this->renderXmlString($createMeetingResponse->getRawXml());
Expand All @@ -182,7 +183,8 @@ public function joinMeeting(string $meetingId, string $role, BigBlueButtonReques
{
$joinParams = new JoinMeetingParameters($meetingId, $fullname, $role);
$presetProcessor = new PresetProcessor();
$joinParams = $presetProcessor->toJoinParameters($p, $joinParams);

$joinParams = $presetProcessor->toJoinParameters($p, $joinParams);

$this->logger->info(
'Meeting join request is going to redirect to the web client.',
Expand Down
2 changes: 1 addition & 1 deletion bbbeasy-backend/app/src/Actions/Rooms/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function beforeroute(): void
$p = $preset->findById($room->getPresetID($room->id)['preset_id']);
$presetProcessor = new PresetProcessor();
$presetData = $presetProcessor->preparePresetData($p->getMyPresetInfos($p));

if (!$presetData[General::GROUP_NAME][General::OPEN_FOR_EVERYONE] && null === $this->session->get('user')) {
$this->logger->warning('Access denied to route ');
$this->f3->error(404);
Expand Down
4 changes: 2 additions & 2 deletions bbbeasy-backend/app/src/Data/PresetData.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ class PresetData

public function setData($category, $subCategory, $value): void
{
if(!is_null($value) && !empty(($value))){
if (null !== $value || (\is_string($value) && !empty($value))) {
$this->data[$category][$subCategory] = $value;
}

}

public function getData($category, $subCategory)
{
// @fixme: should return null if not found
// if (\array_key_exists($category, $this->data) && \array_key_exists($category, $this->data[$category])) {
return $this->data[$category][$subCategory];
// }
Expand Down
2 changes: 1 addition & 1 deletion bbbeasy-backend/app/src/Enum/Presets/Screenshare.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

class Screenshare extends Enum
{
public const GROUP_NAME = 'BScreenshareranding';
public const GROUP_NAME = 'Screenshare';
public const CONFIGURABLE = 'availability';

public const CONFIGURABLE_TYPE = 'bool';
Expand Down
41 changes: 24 additions & 17 deletions bbbeasy-backend/app/src/Models/PresetSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
*/
class PresetSetting extends BaseModel
{
protected $table = 'preset_settings';
protected const GROUP_NAME = 'GROUP_NAME';
protected $table = 'preset_settings';

public function getDefaultPresetSettings($enabled = false): array
{
Expand All @@ -55,11 +56,11 @@ public function getDefaultPresetSettings($enabled = false): array
$attributes = $class->getReflectionConstants();
foreach ($attributes as $attribute) {
$attributeName = $attribute->name;
if (!str_ends_with($attributeName, '_TYPE')) {
if (self::GROUP_NAME !== $attributeName && !str_ends_with($attributeName, '_TYPE')) {
$subCategory = $class->getConstant($attributeName);
$subCategoryData = [
'name' => $subCategory,
'enabled' => "Layout" == $categoryName ? true : $enabled,
'enabled' => 'Layout' === $categoryName ? true : $enabled,
];
$categoryData['subcategories'][] = $subCategoryData;
}
Expand Down Expand Up @@ -136,23 +137,29 @@ public function getByNameAndGroup(string $name,string $group): self
public function savePresetSettings(array $presets): bool|string
{
foreach ($presets as $preset) {
// var_dump($preset['name']);

$subcategories = $preset['subcategories'];

foreach ($subcategories as $subcategory) {
$presetSetting = new self();
$presetSetting->group = $preset['name'];
$presetSetting->name = $subcategory['name'];
$presetSetting->enabled = $subcategory['enabled'];

// @fixme: should not have embedded try/catch here
try {
$presetSetting->save();
} catch (\Exception $e) {
$message = $e->getMessage();
$this->logger->error('Initial application setup : Preset setting could not be added', ['error' => $message]);

return $message;
if ($subcategory['name'] !== str_replace(' ', '', $preset['name'])) {
$presetSetting = new self();
$presetSetting->group = $preset['name'];
$presetSetting->name = $subcategory['name'];
$presetSetting->enabled = $subcategory['enabled'];

// @fixme: should not have embedded try/catch here
try {
$presetSetting->save();
} catch (\Exception $e) {
$message = $e->getMessage();
$this->logger->error('Initial application setup : Preset setting could not be added', ['error' => $message]);

return $message;
}

$this->logger->info('Initial application setup : Add preset setting', ['preset' => $presetSetting->toArray()]);
}
$this->logger->info('Initial application setup : Add preset setting', ['preset' => $presetSetting->toArray()]);
}
}

Expand Down
15 changes: 12 additions & 3 deletions bbbeasy-backend/app/src/Utils/PresetProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function toCreateMeetingParams($preset, $createParams)
$presetsData->setData(BreakoutRooms::GROUP_NAME, BreakoutRooms::PRIVATE_CHAT, $preparePresetData[BreakoutRooms::GROUP_NAME][BreakoutRooms::PRIVATE_CHAT]);

$presetsData->setData(General::GROUP_NAME, General::DURATION, $preparePresetData[General::GROUP_NAME][General::DURATION]);

$presetsData->setData(General::GROUP_NAME, General::MAXIMUM_PARTICIPANTS, $preparePresetData[General::GROUP_NAME][General::MAXIMUM_PARTICIPANTS]);

$presetsData->setData(GuestPolicy::GROUP_NAME, GuestPolicy::POLICY, $preparePresetData[GuestPolicy::GROUP_NAME][GuestPolicy::POLICY]);
Expand All @@ -96,6 +97,7 @@ public function toCreateMeetingParams($preset, $createParams)

// Get preset data to create meeting parameters
$createParams->setMuteOnStart($presetsData->getData(Audio::GROUP_NAME, Audio::USERS_JOIN_MUTED));

$createParams->setAllowModsToUnmuteUsers($presetsData->getData(Audio::GROUP_NAME, Audio::MODERATORS_ALLOWED_TO_UNMUTE_USERS));
// $createParams->setListenOnlyEnabled($presetData->getData(Audio::GROUP_NAME, Audio::LISTEN_ONLY_ENABLED));
// $createParams->setSkipEchoTest($presetData->getData(Audio::GROUP_NAME, Audio::SKIP_ECHO_TEST));
Expand All @@ -108,7 +110,7 @@ public function toCreateMeetingParams($preset, $createParams)
$createParams->setBreakoutRoomsEnabled($presetsData->getData(BreakoutRooms::GROUP_NAME, BreakoutRooms::CONFIGURABLE));
$createParams->setBreakoutRoomsRecord($presetsData->getData(BreakoutRooms::GROUP_NAME, BreakoutRooms::RECORDING));

// $createParams->setBreakoutRoomsPrivateChatEnabled($presetsData->getData(BreakoutRooms::GROUP_NAME, BreakoutRooms::PRIVATE_CHAT));
$createParams->setBreakoutRoomsPrivateChatEnabled(null !== $presetsData->getData(BreakoutRooms::GROUP_NAME, BreakoutRooms::PRIVATE_CHAT) ? $presetsData->getData(BreakoutRooms::GROUP_NAME, BreakoutRooms::PRIVATE_CHAT) : true);

$createParams->setDuration($presetsData->getData(General::GROUP_NAME, General::DURATION));
$createParams->setMaxParticipants($presetsData->getData(General::GROUP_NAME, General::MAXIMUM_PARTICIPANTS));
Expand Down Expand Up @@ -152,10 +154,17 @@ public function toCreateMeetingParams($preset, $createParams)

public function toJoinParameters($preset, $joinParams)
{
$presetData = $this->preparePresetData($preset);
$presetsData = new PresetData();
$preparePresetData = $this->preparePresetData($preset);

$joinParams->setRedirect(false);
// Set the preset data
$presetsData->setData(Audio::GROUP_NAME, Audio::LISTEN_ONLY_ENABLED, $preparePresetData[Audio::GROUP_NAME][Audio::LISTEN_ONLY_ENABLED]);
$presetsData->setData(Audio::GROUP_NAME, Audio::SKIP_ECHO_TEST, $preparePresetData[Audio::GROUP_NAME][Audio::SKIP_ECHO_TEST]);

$joinParams->addUserData('bbb_force_listen_only', $presetsData->getData(Audio::GROUP_NAME, Audio::LISTEN_ONLY_ENABLED));

$joinParams->addUserData('bbb_skip_check_audio', $presetsData->getData(Audio::GROUP_NAME, Audio::SKIP_ECHO_TEST));
$joinParams->setRedirect(false);

return $joinParams;
}
Expand Down
Loading

0 comments on commit 0b53cf9

Please sign in to comment.