Skip to content

Commit

Permalink
Merge pull request #8 from mynaparrot/api_change
Browse files Browse the repository at this point in the history
impl: copyright conf + is_active
  • Loading branch information
jibon57 authored May 3, 2024
2 parents 71529c9 + 16adb8a commit 1185908
Show file tree
Hide file tree
Showing 7 changed files with 141 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
26 changes: 19 additions & 7 deletions examples/plugNmeetConnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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((int)$roomBreakoutRoomFeatures['allowed_number_rooms']);
}
$features->setBreakoutRoomFeatures($breakoutRoomFeatures);
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down
16 changes: 13 additions & 3 deletions examples/quickJoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href=\"https://www.plugnmeet.org\" target=\"_blank\">plugNmeet</a>"
)
);
$isRoomActive = false;
Expand All @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions examples/webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -43,7 +43,7 @@
$connect = new plugNmeetConnect($config);
$deco = $connect->getPlugnmeet()->decodeJWTData($hash);

if (!$deco || !isset($deco->sha256)) {
if (!isset($deco->sha256)) {
return;
}

Expand Down
70 changes: 70 additions & 0 deletions src/Parameters/CopyrightConfParameters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace Mynaparrot\Plugnmeet\Parameters;

/**
*
*/
class CopyrightConfParameters
{
/**
* @var bool
*/
protected $display = true;
/**
* @var string
*/
protected $text = "Powered by <a href=\"https://www.plugnmeet.org\" target=\"_blank\">plugNmeet</a>";

/**
*
*/
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()
);
}
}
25 changes: 25 additions & 0 deletions src/Parameters/RoomMetadataParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ class RoomMetadataParameters
* @var LockSettingsParameters
*/
protected $defaultLockSettings;
/**
* @var CopyrightConfParameters
*/
protected $copyrightConf;
/**
* @var string
*/
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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();
}
Expand Down
11 changes: 11 additions & 0 deletions src/Responses/IsRoomActiveResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 1185908

Please sign in to comment.