From df32f39c7080399b8c06bff4d9aa7f9120834093 Mon Sep 17 00:00:00 2001 From: "Jibon L. Costa" Date: Sun, 21 Apr 2024 13:32:50 +0600 Subject: [PATCH 1/4] impl: copyright conf + is_active --- examples/plugNmeetConnect.php | 26 +++++--- examples/quickJoin.php | 16 ++++- src/Parameters/CopyrightConfParameters.php | 70 ++++++++++++++++++++++ src/Parameters/RoomMetadataParameters.php | 25 ++++++++ src/Responses/IsRoomActiveResponse.php | 11 ++++ 5 files changed, 138 insertions(+), 10 deletions(-) create mode 100644 src/Parameters/CopyrightConfParameters.php diff --git a/examples/plugNmeetConnect.php b/examples/plugNmeetConnect.php index 00db259..8b45438 100755 --- a/examples/plugNmeetConnect.php +++ b/examples/plugNmeetConnect.php @@ -25,6 +25,7 @@ use Mynaparrot\Plugnmeet\Parameters\AnalyticsDownloadTokenParameters; use Mynaparrot\Plugnmeet\Parameters\BreakoutRoomFeaturesParameters; use Mynaparrot\Plugnmeet\Parameters\ChatFeaturesParameters; +use Mynaparrot\Plugnmeet\Parameters\CopyrightConfParameters; use Mynaparrot\Plugnmeet\Parameters\CreateRoomParameters; use Mynaparrot\Plugnmeet\Parameters\DeleteAnalyticsParameters; use Mynaparrot\Plugnmeet\Parameters\DeleteRecordingParameters; @@ -252,10 +253,8 @@ public function createRoom(string $roomId, string $roomTitle, string $welcomeMes if (isset($roomWaitingRoomFeatures['is_active'])) { $waitingRoomFeatures->setIsActive($roomWaitingRoomFeatures['is_active']); } - if (isset($roomWaitingRoomFeatures['waiting_room_msg'])) { - if (!empty($roomWaitingRoomFeatures['waiting_room_msg'])) { - $waitingRoomFeatures->setWaitingRoomMsg($roomWaitingRoomFeatures['waiting_room_msg']); - } + if (!empty($roomWaitingRoomFeatures['waiting_room_msg'])) { + $waitingRoomFeatures->setWaitingRoomMsg($roomWaitingRoomFeatures['waiting_room_msg']); } $features->setWaitingRoomFeatures($waitingRoomFeatures); } @@ -267,9 +266,7 @@ public function createRoom(string $roomId, string $roomTitle, string $welcomeMes $breakoutRoomFeatures->setIsAllow($roomBreakoutRoomFeatures['is_allow']); } if (isset($roomBreakoutRoomFeatures['allowed_number_rooms'])) { - if (!empty($roomBreakoutRoomFeatures['allowed_number_rooms'])) { - $breakoutRoomFeatures->setAllowedNumberRooms($roomBreakoutRoomFeatures['allowed_number_rooms']); - } + $breakoutRoomFeatures->setAllowedNumberRooms($roomBreakoutRoomFeatures['allowed_number_rooms']); } $features->setBreakoutRoomFeatures($breakoutRoomFeatures); } @@ -366,6 +363,20 @@ public function createRoom(string $roomId, string $roomTitle, string $welcomeMes $metadata->setDefaultLockSettings($lockSettings); } + if (isset($roomMetadata['copyright_conf'])) { + $conf = $roomMetadata['copyright_conf']; + $copyrightConf = new CopyrightConfParameters(); + + if (isset($conf["display"])) { + $copyrightConf->setDisplay($conf["display"]); + } + if (isset($conf["text"])) { + $copyrightConf->setText($conf["text"]); + } + + $metadata->setCopyrightConf($copyrightConf); + } + $roomCreateParams = new CreateRoomParameters(); $roomCreateParams->setRoomId($roomId); if ($max_participants > 0) { @@ -386,6 +397,7 @@ public function createRoom(string $roomId, string $roomTitle, string $welcomeMes * @param bool $isAdmin * @param bool $isHidden * @param UserMetadataParameters|null $userMetadata + * @param LockSettingsParameters|null $lockSettings * @return GenerateJoinTokenResponse */ public function getJoinToken(string $roomId, string $name, string $userId, bool $isAdmin, bool $isHidden = false, UserMetadataParameters $userMetadata = null, LockSettingsParameters $lockSettings = null): GenerateJoinTokenResponse diff --git a/examples/quickJoin.php b/examples/quickJoin.php index 1eb9b61..5519311 100644 --- a/examples/quickJoin.php +++ b/examples/quickJoin.php @@ -106,6 +106,12 @@ "lock_chat_send_message" => false, "lock_chat_file_share" => false, "lock_private_chat" => false // user can always send private message to moderator + ), + // copyright_conf will only work if server config has been + // set true for `allow_override` otherwise this will ignore + "copyright_conf" => array( + "display" => true, + "text" => "Powered by plugNmeet" ) ); $isRoomActive = false; @@ -114,9 +120,13 @@ try { $res = $connect->isRoomActive($roomId); - $isRoomActive = $res->getStatus(); - $output->status = true; - $output->msg = $res->getResponseMsg(); + if (!$res->getStatus()) { + $output->msg = $res->getResponseMsg(); + } else { + $isRoomActive = $res->isActive(); + $output->status = true; + } + } catch (Exception $e) { $output->msg = $e->getMessage(); } diff --git a/src/Parameters/CopyrightConfParameters.php b/src/Parameters/CopyrightConfParameters.php new file mode 100644 index 0000000..af2ed35 --- /dev/null +++ b/src/Parameters/CopyrightConfParameters.php @@ -0,0 +1,70 @@ +plugNmeet"; + + /** + * + */ + public function __construct() + { + } + + /** + * @return bool + */ + public function isDisplay(): bool + { + return $this->display; + } + + /** + * @param bool $display + * @return void + */ + public function setDisplay(bool $display): void + { + $this->display = filter_var($display, FILTER_VALIDATE_BOOLEAN); + } + + /** + * @return string + */ + public function getText(): string + { + return $this->text; + } + + /** + * @param string $text + * @return void + */ + public function setText(string $text): void + { + $this->text = $text; + } + + /** + * @return array + */ + public function buildBody(): array + { + return array( + "display" => $this->isDisplay(), + "text" => $this->getText() + ); + } +} diff --git a/src/Parameters/RoomMetadataParameters.php b/src/Parameters/RoomMetadataParameters.php index 8807497..2f11387 100644 --- a/src/Parameters/RoomMetadataParameters.php +++ b/src/Parameters/RoomMetadataParameters.php @@ -54,6 +54,10 @@ class RoomMetadataParameters * @var LockSettingsParameters */ protected $defaultLockSettings; + /** + * @var CopyrightConfParameters + */ + protected $copyrightConf; /** * @var string */ @@ -162,6 +166,23 @@ public function setDefaultLockSettings(LockSettingsParameters $defaultLockSettin $this->defaultLockSettings = $defaultLockSettings; } + /** + * @return CopyrightConfParameters + */ + public function getCopyrightConf(): CopyrightConfParameters + { + return $this->copyrightConf; + } + + /** + * @param CopyrightConfParameters $copyrightConf + * @return void + */ + public function setCopyrightConf(CopyrightConfParameters $copyrightConf): void + { + $this->copyrightConf = $copyrightConf; + } + /** * @return string */ @@ -207,6 +228,10 @@ public function buildBody(): array $body["default_lock_settings"] = $this->getDefaultLockSettings()->buildBody(); } + if ($this->copyrightConf !== null) { + $body["copyright_conf"] = $this->getCopyrightConf()->buildBody(); + } + if (!empty($this->extraData)) { $body["extra_data"] = $this->getExtraData(); } diff --git a/src/Responses/IsRoomActiveResponse.php b/src/Responses/IsRoomActiveResponse.php index 62cceae..6e70ed8 100644 --- a/src/Responses/IsRoomActiveResponse.php +++ b/src/Responses/IsRoomActiveResponse.php @@ -26,4 +26,15 @@ class IsRoomActiveResponse extends BaseResponse { + /** + * @return bool + */ + public function isActive(): bool + { + if (isset($this->rawResponse->is_active)) { + return $this->rawResponse->is_active; + } + + return false; + } } From 40d25b6f96527cb4366930496b9e48124098b9c0 Mon Sep 17 00:00:00 2001 From: "Jibon L. Costa" Date: Sun, 21 Apr 2024 13:33:35 +0600 Subject: [PATCH 2/4] bump version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bf92758..b3a3f39 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "plugNmeet PHP SDK", "type": "library", "license": "MIT", - "version": "1.4.2", + "version": "1.5.0", "autoload": { "psr-4": { "Mynaparrot\\Plugnmeet\\": "src/" From c2a48521213f5b4c24959b2c69a62bb936dc5202 Mon Sep 17 00:00:00 2001 From: "Jibon L. Costa" Date: Sun, 21 Apr 2024 21:06:24 +0600 Subject: [PATCH 3/4] clean up --- examples/webhook.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/webhook.php b/examples/webhook.php index ed78a09..d840626 100644 --- a/examples/webhook.php +++ b/examples/webhook.php @@ -28,7 +28,7 @@ return; } -$hash = isset($_SERVER["HTTP_AUTHORIZATION"]) ? $_SERVER["HTTP_AUTHORIZATION"] : $_SERVER["HTTP_HASH_TOKEN"]; +$hash = $_SERVER["HTTP_AUTHORIZATION"] ?? $_SERVER["HTTP_HASH_TOKEN"]; if (empty($hash)) { return; } @@ -43,7 +43,7 @@ $connect = new plugNmeetConnect($config); $deco = $connect->getPlugnmeet()->decodeJWTData($hash); -if (!$deco || !isset($deco->sha256)) { +if (!isset($deco->sha256)) { return; } From 16adb8a2c01d5d2b5b32ddeb56face4453fd75a1 Mon Sep 17 00:00:00 2001 From: "Jibon L. Costa" Date: Sun, 21 Apr 2024 21:58:14 +0600 Subject: [PATCH 4/4] clean up --- examples/plugNmeetConnect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/plugNmeetConnect.php b/examples/plugNmeetConnect.php index 8b45438..856dc8b 100755 --- a/examples/plugNmeetConnect.php +++ b/examples/plugNmeetConnect.php @@ -266,7 +266,7 @@ public function createRoom(string $roomId, string $roomTitle, string $welcomeMes $breakoutRoomFeatures->setIsAllow($roomBreakoutRoomFeatures['is_allow']); } if (isset($roomBreakoutRoomFeatures['allowed_number_rooms'])) { - $breakoutRoomFeatures->setAllowedNumberRooms($roomBreakoutRoomFeatures['allowed_number_rooms']); + $breakoutRoomFeatures->setAllowedNumberRooms((int)$roomBreakoutRoomFeatures['allowed_number_rooms']); } $features->setBreakoutRoomFeatures($breakoutRoomFeatures); }