Skip to content

Commit

Permalink
聊天室更新用isset判断
Browse files Browse the repository at this point in the history
  • Loading branch information
salamander committed Jan 22, 2019
1 parent 1ce03b9 commit 6b9b799
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions src/Api/ChatRoom.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ public function get($roomId, $needOnlineUserCount = false) {
return $res['chatroom'];
}


/**
* 批量查询聊天室信息
* @param array $roomIds
* @param bool $needOnlineUserCount
* @return array
* @return mixed
* @throws YunXinArgExcetption
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \YunXinHelper\Exception\YunXinBusinessException
* @throws \YunXinHelper\Exception\YunXinInnerException
* @throws \YunXinHelper\Exception\YunXinNetworkException
*/
public function getBatch(array $roomIds, $needOnlineUserCount = false) {
Expand All @@ -148,23 +148,25 @@ public function getBatch(array $roomIds, $needOnlineUserCount = false) {
return $res;
}


/**
* 更新聊天室
* @param $creator
* @param $name
* @param string $announcement
* @param string $broadcasturl
* @param string $ext
* @param int $queuelevel
* @return array
* @param $roomId
* @param null $name
* @param null $announcement
* @param null $broadcasturl
* @param null $ext
* @param bool $needNotify
* @param null $notifyExt
* @param null $queuelevel
* @return mixed
* @throws YunXinArgExcetption
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \YunXinHelper\Exception\YunXinBusinessException
* @throws \YunXinHelper\Exception\YunXinInnerException
* @throws \YunXinHelper\Exception\YunXinNetworkException
*/
public function update($roomId, $name = '', $announcement = '', $broadcasturl = '', $ext = '', $needNotify = TRUE,
$notifyExt = '', $queuelevel = NULL) {
public function update($roomId, $name = NULL, $announcement = NULL, $broadcasturl = NULL, $ext = NULL, $needNotify = TRUE,
$notifyExt = NULL, $queuelevel = NULL) {
if (!is_int($roomId)) {
throw new YunXinArgExcetption('房间id不合法!');
}
Expand All @@ -181,7 +183,7 @@ public function update($roomId, $name = '', $announcement = '', $broadcasturl =
throw new YunXinArgExcetption('聊天室扩展字段超过限制!');
}
$levelLegalArr = [self::QUEUE_LEVEL_ALL, self::QUEUE_LEVEL_ADMIN];
if (!in_array($queuelevel, $levelLegalArr)) {
if (is_numeric($queuelevel) && !in_array($queuelevel, $levelLegalArr)) {
throw new YunXinArgExcetption('聊天室queuelevel参数不合法');
}
if (strlen($notifyExt) > self::CHAT_ROOM_NOTIFY_EXT_LIMIT) {
Expand All @@ -190,22 +192,22 @@ public function update($roomId, $name = '', $announcement = '', $broadcasturl =
$data = [
'roomid' => $roomId,
];
if ($name) {
if (isset($name)) {
$data['name'] = $name;
}
if ($announcement) {
if (isset($announcement)) {
$data['announcement'] = $announcement;
}
if ($broadcasturl) {
if (isset($broadcasturl)) {
$data['broadcasturl'] = $broadcasturl;
}
if ($ext) {
if (isset($ext)) {
$data['ext'] = $ext;
}
if (isset($needNotify)) {
$data['needNotify'] = $needNotify;
}
if ($notifyExt) {
if (isset($notifyExt)) {
$data['notifyExt'] = $notifyExt;
}
if (isset($queuelevel)) {
Expand All @@ -216,15 +218,17 @@ public function update($roomId, $name = '', $announcement = '', $broadcasturl =
return $res['chatroom'];
}


/**
* 修改聊天室开/关闭状态
* @param $roomId
* @param string $operator 必须是创建者才可以操作
* @param bool $valid
* @param $operator
* @param $valid
* @return mixed
* @throws YunXinArgExcetption
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \YunXinHelper\Exception\YunXinBusinessException
* @throws \YunXinHelper\Exception\YunXinInnerException
* @throws \YunXinHelper\Exception\YunXinNetworkException
*/
public function toggleCloseStatus($roomId, $operator, $valid) {
Expand Down

0 comments on commit 6b9b799

Please sign in to comment.