Skip to content

Commit

Permalink
value checker & default options
Browse files Browse the repository at this point in the history
  • Loading branch information
jibon57 committed May 3, 2022
1 parent 78ae606 commit c408260
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 64 deletions.
84 changes: 63 additions & 21 deletions examples/plugNmeetConnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,41 +103,65 @@ public function createRoom(string $roomId, string $roomTitle, string $welcomeMes
{
$roomFeatures = $roomMetadata['room_features'];
$features = new RoomFeaturesParameters();
$features->setAllowWebcams($roomFeatures['allow_webcams']);
$features->setMuteOnStart($roomFeatures['mute_on_start']);
$features->setAllowScreenShare($roomFeatures['allow_screen_share']);
$features->setAllowRecording($roomFeatures['allow_recording']);
$features->setAllowRTMP($roomFeatures['allow_rtmp']);
$features->setAllowViewOtherWebcams($roomFeatures['allow_view_other_webcams']);
$features->setAllowViewOtherParticipants($roomFeatures['allow_view_other_users_list']);
$features->setAdminOnlyWebcams($roomFeatures['admin_only_webcams']);

if (isset($roomFeatures['allow_webcams'])) {
$features->setAllowWebcams($roomFeatures['allow_webcams']);
}
if (isset($roomFeatures['mute_on_start'])) {
$features->setMuteOnStart($roomFeatures['mute_on_start']);
}
if (isset($roomFeatures['allow_recording'])) {
$features->setAllowRecording($roomFeatures['allow_recording']);
}
if (isset($roomFeatures['allow_rtmp'])) {
$features->setAllowRTMP($roomFeatures['allow_rtmp']);
}
if (isset($roomFeatures['allow_view_other_webcams'])) {
$features->setAllowViewOtherWebcams($roomFeatures['allow_view_other_webcams']);
}
if (isset($roomFeatures['allow_view_other_users_list'])) {
$features->setAllowViewOtherParticipants($roomFeatures['allow_view_other_users_list']);
}
if (isset($roomFeatures['admin_only_webcams'])) {
$features->setAdminOnlyWebcams($roomFeatures['admin_only_webcams']);
}

if (isset($roomMetadata['chat_features'])) {
$roomChatFeatures = $roomMetadata['chat_features'];
$chatFeatures = new ChatFeaturesParameters();
$chatFeatures->setAllowChat($roomChatFeatures['allow_chat']);
$chatFeatures->setAllowFileUpload($roomChatFeatures['allow_file_upload']);
if (isset($roomChatFeatures['allow_chat'])) {
$chatFeatures->setAllowChat($roomChatFeatures['allow_chat']);
}
if (isset($roomChatFeatures['allow_file_upload'])) {
$chatFeatures->setAllowFileUpload($roomChatFeatures['allow_file_upload']);
}
$features->setChatFeatures($chatFeatures);
}

if (isset($roomMetadata['shared_note_pad_features'])) {
$roomSharedNotepadFeatures = $roomMetadata['shared_note_pad_features'];
$sharedNotePadFeatures = new SharedNotePadFeaturesParameters();
$sharedNotePadFeatures->setAllowedSharedNotePad($roomSharedNotepadFeatures['allowed_shared_note_pad']);
if (isset($roomSharedNotepadFeatures['allowed_shared_note_pad'])) {
$sharedNotePadFeatures->setAllowedSharedNotePad($roomSharedNotepadFeatures['allowed_shared_note_pad']);
}
$features->setSharedNotePadFeatures($sharedNotePadFeatures);
}

if (isset($roomMetadata['whiteboard_features'])) {
$roomWhiteboardFeatures = $roomMetadata['whiteboard_features'];
$whiteboardFeatures = new WhiteboardFeaturesParameters();
$whiteboardFeatures->setAllowedWhiteboard($roomWhiteboardFeatures['allowed_whiteboard']);
if (isset($roomWhiteboardFeatures['allowed_whiteboard'])) {
$whiteboardFeatures->setAllowedWhiteboard($roomWhiteboardFeatures['allowed_whiteboard']);
}
$features->setWhiteboardFeatures($whiteboardFeatures);
}

if (isset($roomMetadata['external_media_player_features'])) {
$roomExternalMediaPlayerFeatures = $roomMetadata['external_media_player_features'];
$externalMediaPlayerFeatures = new ExternalMediaPlayerFeaturesParameters();
$externalMediaPlayerFeatures->setAllowedExternalMediaPlayer($roomExternalMediaPlayerFeatures['allowed_external_media_player']);
if (isset($roomExternalMediaPlayerFeatures['allowed_external_media_player'])) {
$externalMediaPlayerFeatures->setAllowedExternalMediaPlayer($roomExternalMediaPlayerFeatures['allowed_external_media_player']);
}
$features->setExternalMediaPlayerFeatures($externalMediaPlayerFeatures);
}

Expand All @@ -150,14 +174,32 @@ public function createRoom(string $roomId, string $roomTitle, string $welcomeMes
if (isset($roomMetadata['default_lock_settings'])) {
$defaultLocks = $roomMetadata['default_lock_settings'];
$lockSettings = new LockSettingsParameters();
$lockSettings->setLockMicrophone($defaultLocks['lock_microphone']);
$lockSettings->setLockWebcam($defaultLocks['lock_webcam']);
$lockSettings->setLockScreenSharing($defaultLocks['lock_screen_sharing']);
$lockSettings->setLockWhiteboard($defaultLocks['lock_whiteboard']);
$lockSettings->setLockSharedNotepad($defaultLocks['lock_shared_notepad']);
$lockSettings->setLockChat($defaultLocks['lock_chat']);
$lockSettings->setLockChatSendMessage($defaultLocks['lock_chat_send_message']);
$lockSettings->setLockChatFileShare($defaultLocks['lock_chat_file_share']);

if (isset($defaultLocks['lock_microphone'])) {
$lockSettings->setLockMicrophone($defaultLocks['lock_microphone']);
}
if (isset($defaultLocks['lock_webcam'])) {
$lockSettings->setLockWebcam($defaultLocks['lock_webcam']);
}
if (isset($defaultLocks['lock_screen_sharing'])) {
$lockSettings->setLockScreenSharing($defaultLocks['lock_screen_sharing']);
}
if (isset($defaultLocks['lock_whiteboard'])) {
$lockSettings->setLockWhiteboard($defaultLocks['lock_whiteboard']);
}
if (isset($defaultLocks['lock_shared_notepad'])) {
$lockSettings->setLockSharedNotepad($defaultLocks['lock_shared_notepad']);
}
if (isset($defaultLocks['lock_chat'])) {
$lockSettings->setLockChat($defaultLocks['lock_chat']);
}
if (isset($defaultLocks['lock_chat_send_message'])) {
$lockSettings->setLockChatSendMessage($defaultLocks['lock_chat_send_message']);
}
if (isset($defaultLocks['lock_chat_file_share'])) {
$lockSettings->setLockChatFileShare($defaultLocks['lock_chat_file_share']);
}

$metadata->setDefaultLockSettings($lockSettings);
}

Expand Down
28 changes: 18 additions & 10 deletions src/Parameters/ChatFeaturesParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ class ChatFeaturesParameters
/**
* @var bool
*/
protected $allowChat;
protected $allowChat = true;
/**
* @var bool
*/
protected $allowFileUpload;
protected $allowFileUpload = true;
/**
* @var string[]
*/
protected $allowedFileTypes;
protected $allowedFileTypes = array();
/**
* @var int
*/
protected $maxFileSize;
protected $maxFileSize = 0;

/**
*
Expand Down Expand Up @@ -95,9 +95,9 @@ public function getAllowedFileTypes()
/**
* @param string[] $allowedFileTypes
*/
public function setAllowedFileTypes($allowedFileTypes)
public function setAllowedFileTypes(array $allowedFileTypes)
{
$this->allowedFileTypes = filter_var($allowedFileTypes, FILTER_VALIDATE_BOOLEAN);
$this->allowedFileTypes = $allowedFileTypes;
}

/**
Expand All @@ -121,11 +121,19 @@ public function setMaxFileSize($maxFileSize)
*/
public function buildBody()
{
return array(
$body = array(
"allow_chat" => $this->allowChat,
"allow_file_upload" => $this->allowFileUpload,
"allowed_file_types" => $this->getAllowedFileTypes(),
"max_file_size" => $this->maxFileSize
"allow_file_upload" => $this->allowFileUpload
);

if (!empty($this->allowedFileTypes)) {
$body['allowed_file_types'] = $this->allowedFileTypes;
}

if ($this->maxFileSize > 0) {
$body['max_file_size'] = $this->maxFileSize;
}

return $body;
}
}
4 changes: 2 additions & 2 deletions src/Parameters/CreateRoomParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class CreateRoomParameters
/**
* @var int
*/
protected $emptyTimeout;
protected $emptyTimeout = 0;
/**
* @var int
*/
protected $maxParticipants;
protected $maxParticipants = 0;
/**
* @var RoomMetadataParameters
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Parameters/ExternalMediaPlayerFeaturesParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ExternalMediaPlayerFeaturesParameters
/**
* @var bool
*/
protected $allowedExternalMediaPlayer;
protected $allowedExternalMediaPlayer = true;

public function __construct()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Parameters/FetchRecordingsParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FetchRecordingsParameters
/**
* @var array
*/
protected $roomIds;
protected $roomIds = array();
/**
* @var int
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Parameters/GenerateJoinTokenParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ public function buildBody()
"is_hidden" => $this->isHidden
)
);
if ($this->userMetadata) {

if ($this->userMetadata !== null) {
$body["user_info"]["user_metadata"] = $this->userMetadata->buildBody();
}

Expand Down
39 changes: 29 additions & 10 deletions src/Parameters/LockSettingsParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,34 @@ public function setLockChatFileShare($lockChatFileShare)
*/
public function buildBody()
{
return array(
'lock_microphone' => $this->lockMicrophone,
'lock_webcam' => $this->lockWebcam,
'lock_screen_sharing' => $this->lockScreenSharing,
'lock_whiteboard' => $this->lockWhiteboard,
'lock_shared_notepad' => $this->lockSharedNotepad,
'lock_chat' => $this->lockChat,
'lock_chat_send_message' => $this->lockChatSendMessage,
'lock_chat_file_share' => $this->lockChatFileShare,
);

$body = array();

if ($this->lockMicrophone !== null) {
$body["lock_microphone"] = $this->lockMicrophone;
}
if ($this->lockWebcam !== null) {
$body["lock_webcam"] = $this->lockWebcam;
}
if ($this->lockScreenSharing !== null) {
$body["lock_screen_sharing"] = $this->lockScreenSharing;
}
if ($this->lockWhiteboard !== null) {
$body["lock_whiteboard"] = $this->lockWhiteboard;
}
if ($this->lockSharedNotepad !== null) {
$body["lock_shared_notepad"] = $this->lockSharedNotepad;
}
if ($this->lockChat !== null) {
$body["lock_chat"] = $this->lockChat;
}
if ($this->lockChatSendMessage !== null) {
$body["lock_chat_send_message"] = $this->lockChatSendMessage;
}
if ($this->lockChatFileShare !== null) {
$body["lock_chat_file_share"] = $this->lockChatFileShare;
}

return $body;
}
}
16 changes: 8 additions & 8 deletions src/Parameters/RoomFeaturesParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,35 @@ class RoomFeaturesParameters
/**
* @var bool
*/
protected $allowWebcams;
protected $allowWebcams = true;
/**
* @var bool
*/
protected $muteOnStart;
protected $muteOnStart = false;
/**
* @var bool
*/
protected $allowScreenShare;
protected $allowScreenShare = true;
/**
* @var bool
*/
protected $allowRecording;
protected $allowRecording = true;
/**
* @var bool
*/
protected $allowRTMP;
protected $allowRTMP = true;
/**
* @var bool
*/
protected $adminOnlyWebcams;
protected $adminOnlyWebcams = false;
/**
* @var bool
*/
protected $allowViewOtherWebcams;
protected $allowViewOtherWebcams = true;
/**
* @var bool
*/
protected $allowViewOtherParticipants;
protected $allowViewOtherParticipants = true;
/**
* @var ChatFeaturesParameters
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Parameters/RoomMetadataParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,19 @@ public function buildBody()
"room_title" => $this->roomTitle,
);

if ($this->welcomeMessage) {
if (!empty($this->welcomeMessage)) {
$body["welcome_message"] = $this->welcomeMessage;
}

if ($this->webhookUrl) {
if (!empty($this->webhookUrl)) {
$body["webhook_url"] = $this->webhookUrl;
}

if ($this->features) {
if ($this->features !== null) {
$body["room_features"] = $this->features->buildBody();
}

if ($this->defaultLockSettings) {
if ($this->defaultLockSettings !== null) {
$body["default_lock_settings"] = $this->defaultLockSettings->buildBody();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Parameters/SharedNotePadFeaturesParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SharedNotePadFeaturesParameters
/**
* @var bool
*/
protected $allowedSharedNotePad;
protected $allowedSharedNotePad = true;

/**
*
Expand Down
13 changes: 9 additions & 4 deletions src/Parameters/UserMetadataParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,15 @@ public function setLockSettings($lockSettings)
*/
public function buildBody()
{
$body = array(
"profile_pic" => $this->profilePic,
"lock_settings" => $this->lockSettings->buildBody()
);
$body = array();

if (!empty($this->profilePic)) {
$body["profile_pic"] = $this->profilePic;
}

if ($this->lockSettings !== null) {
$body["lock_settings"] = $this->lockSettings->buildBody();
}

return $body;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Parameters/WhiteboardFeaturesParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class WhiteboardFeaturesParameters
/**
* @var bool
*/
protected $allowedWhiteboard;
protected $allowedWhiteboard = true;

/**
*
Expand Down

0 comments on commit c408260

Please sign in to comment.