123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900 |
- <?php
- class GroupController extends BaseController {
- protected $ajaxLoginActions = [
- 'sendMsg',
- 'sendImageMsg',
- 'pinMsg',
- 'unpinMsg',
- 'getFriends',
- 'create',
- 'join',
- 'leave',
- 'blockUser',
- 'unblockUser',
- 'invites',
- 'removes',
- 'changeName',
- 'changeTitle',
- 'changeNotice',
- 'changeCover',
- 'addAdmin',
- 'removeAdmin',
- 'auth',
- 'changeCreator',
- ];
- public function __construct() {
- parent::__construct(true);
- }
-
- public function actionInfo($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群id'],
- ];
- Param::checkParam2($rules, $args);
- $user_id = User::getUserId();
- $objGroupInfo = new GroupInfo();
- $_field = 'group_id, group_name, group_title, group_notice, cover_photo, member_num, creator, url, server_id, is_public';
- $group = $objGroupInfo->objTable->getRow($args, compact('_field'));
- $group && $group['invite_url'] = GroupInfo::genInviteUrl($group['group_name']);
- $group['increase_num'] = 0;
- $_field = 'user_id, is_admin, is_block, join_time';
- $objUserGroup = new UserGroup();
- $groupUsers = $objUserGroup->objTable->getAll(['group_id' => $args['group_id'], 'state' => 1], ['_field' => $_field, '_sortKey' => 'join_time ASC', '_limit' => 100]);
- $joinMap = arrayFormatKey($groupUsers, 'user_id', 'join_time');
- $user_ids = [];
- $blockList = [];
- $adminList = [];
-
- if ($user_id && !in_array($user_id, array_keys($joinMap))) {
- $_row = $objUserGroup->objTable->getRow(['user_id' => $user_id, 'group_id' => $args['group_id'], 'state' => 1], ['_field' => $_field]);
- if ($_row) {
- $groupUsers[] = $_row;
- $joinMap[$user_id] = $_row['join_time'];
- }
- }
- if (!$group['is_public'] && !$joinMap[$user_id]) {
-
- Response::error(CODE_NO_PERMITION, 'the group is private.');
- }
- foreach ($groupUsers as $_u) {
- $_uid = intval($_u['user_id']);
- $user_ids[] = $_uid;
- $_u['is_block'] && $blockList[] = $_uid;
- $_u['is_admin'] && $adminList[] = $_uid;
- }
-
- $objGroupMsg = new TableHelper('group_msg', 'dw_chat');
- $where2 = [
- 'group_id' => $args['group_id'],
- 'is_pin' => 1,
- '_field' => '`from`, hash, msg, msg_type'
- ];
- $pinMsg = $objGroupMsg->getRow($where2);
- $user_ids[] = $pinMsg['from'];
- $objUserInfo = new TableHelper('user_info', 'dw_chat');
- $_field = 'user_id, user_name, nick_name, cover_photo';
- $members = $objUserInfo->getAll(['user_id' => $user_ids], compact('_field'));
- coverReplaceArrImage($members, 'cover_photo');
- $members = arrayFormatKey($members, 'user_id');
- $joinTimes = [];
- $adminNum = 0;
- $newMembers = [];
- foreach ($groupUsers as $_u) {
- $_uid = intval($_u['user_id']);
- if ($members[$_uid]) {
- $joinTime = strtotime($joinMap[$_uid]);
- $joinTime < 0 && $joinTime = time();
- if ($_u['is_block']) {
- $members[$_uid]['is_block'] = (int) $_u['is_block'];
- }
- if ($_u['is_admin']) {
- $members[$_uid]['is_admin'] = (int) $_u['is_admin'];
- $joinTime = $adminNum++;
- if ($group['creator'] == $_uid) {
- $members[$_uid]['is_admin'] = 2;
- $joinTime = -1;
- }
- }
- $newMembers[] = $members[$_uid];
- $joinTimes[$_uid] = $joinTime;
- }
- }
-
- $pinMsg = array_merge($pinMsg, arrayFilter($members[$pinMsg['from']], ['user_name', 'nick_name', 'cover_photo']));
- $members = $newMembers;
- array_multisort($joinTimes, SORT_ASC, $members);
- $sessionInfo = null;
- if ($user_id) {
- $objSession = new Session();
- $sessionInfo = $objSession->objTable->getRow(['user_id' => $user_id, 'session_id' => $args['group_id']], ['_field' => 'is_pin, pin_time_int, is_mute']);
- }
- $objGroupEos = new TableHelper('group_eos', 'dw_chat');
- $eosInfo = $objGroupEos->getRow($args);
- return compact('group', 'eosInfo', 'members', 'pinMsg', 'sessionInfo', 'blockList', 'adminList');
- }
-
- public function actionNewMsg($args) {
- $rules = [
- 'group_id' => ['string', 'desc' => '群id'],
- 'client_hash' => ['string', 'nullable' => true, 'desc' => '客户端上的最新消息的hash'],
- ];
- Param::checkParam2($rules, $args);
- $load_type = 0;
- return $this->_msg($args['group_id'], $load_type, $args['client_hash']);
- }
-
- public function actionHistoryMsg($args) {
- $rules = [
- 'group_id' => ['string', 'desc' => '群id'],
- 'client_hash' => ['string', 'desc' => '客户端上的最旧消息的hash'],
- ];
- Param::checkParam2($rules, $args);
- $load_type = -1;
- return $this->_msg($args['group_id'], $load_type, $args['client_hash']);
- }
-
- private function _msg($session_id, $load_type, $client_hash) {
- $userId = User::getUserId();
- $where = compact('session_id');
- if ($userId) {
- $where['user_id'] = $userId;
- }
- $keyWord = [
- '_field' => 'is_group, read_hash, read_num',
- ];
- $objSession = new Session();
- $row = $objSession->objTable->getRow($where, $keyWord);
- if (is_numeric($session_id)) {
- $objGroupInfo = new GroupInfo();
- $objGroupInfo->checkPermission($session_id, $userId);
- }
- $data = $objSession->getMsgList($session_id, $client_hash, $load_type, 1);
- if ($userId && $row) {
- $end = end($data['list']);
- $lastNum = $end['msg_num'];
- if ($lastNum > $row['read_num']) {
- $objSession->updateState($session_id, ['read_num' => $lastNum], ['user_id' => $userId]);
- }
- }
- $data['list'] = array_filter($data['list'], function ($v) {
- return $v['state'] == 1;
- });
- $data['list'] = array_values($data['list']);
- return $data;
- }
-
- public function actionSendMsg($args) {
- $rules = [
- 'group_id' => ['string', 'desc' => '群id'],
- 'msg_type' => ['int', 'nullable' => true, 'default' => 0, 'desc' => '消息类型:0:文本,1:图片,2:视频'],
- 'msg' => ['string', 'desc' => '内容'],
- ];
- Param::checkParam2($rules, $args);
- $userId = User::getUserId();
- $objSession = new Session();
- $data = [];
- try {
- $data = $objSession->sendGroupMsg($userId, $args['group_id'], $args['msg_type'], $args['msg']);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- return $data;
- }
- public function actionSendImageMsg($args) {
- return $this->actionSendFile($args);
- }
-
- public function actionSendFile($args) {
- $args = array_merge($args, $_FILES);
- $rules = [
- 'group_id' => ['string', 'desc' => '群id'],
- 'res' => ['array', 'desc' => '资源文件'],
- ];
- Param::checkParam2($rules, $args);
- $data = null;
- try {
- $msgType = FileUrl::getType($args['res']['type']);
- $maxSize = 1000 * 1000;
- switch ($msgType) {
- case FileUrl::TYPE_IMAGE:
- $maxSize = 3000 * 1000;
- break;
- case FileUrl::TYPE_VIDEO:
- $maxSize = 10000 * 1000;
- break;
- case FileUrl::TYPE_AUDIO:
- $maxSize = 5000 * 1000;
- break;
- default:
- Response::error(CODE_PARAM_ERROR, 'unknown type:' . $args['res']['type']);
- }
- $size = filesize($args['res']['tmp_name']);
- if ($size > $maxSize) {
- Response::error(CODE_PARAM_ERROR, "file is too big. size:{$size}");
- }
- $objFile = new FileUrl();
- $url = $objFile->getFileUrl($args['res']['tmp_name'], $args['res']['name'], $args['res']['type']);
-
- if ($msgType == FileUrl::TYPE_IMAGE) {
- $url = awsReplaceImg($url);
- }
- $msg = Utils::encodeRC4($url);
- $userId = User::getUserId();
- $extInfo = [];
-
- if ($msgType == FileUrl::TYPE_VIDEO) {
- $cover_url = $objFile->getVideoCover($args['res']['tmp_name'], $args['res']['name']);
- $cover_url && $extInfo['cover_url'] = awsReplaceImg($cover_url);
- }
- $objSession = new Session();
- $data = $objSession->sendGroupMsg($userId, $args['group_id'], $msgType, $msg, false, false, $extInfo);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- return $data;
- }
-
- public function actionPinMsg($args) {
- $rules = [
- 'group_id' => ['string', 'desc' => '群id'],
- 'hash' => ['string', 'desc' => '消息hash'],
- ];
- Param::checkParam2($rules, $args);
- $group_id = (int) $args['group_id'];
- $this->_checkGroupAdmin($group_id);
- $objGroupMsg = new TableHelper('group_msg', 'dw_chat');
- $_field = '`from`, hash, msg, msg_type';
- $row = $objGroupMsg->getRow($args, compact('_field'));
- if (!$row) {
- Response::error(CODE_NORMAL_ERROR, 'can not find the msg');
- }
- $where2 = [
- 'group_id' => $group_id,
- 'is_pin' => 1,
- ];
-
- $objGroupMsg->updateObject(['is_pin' => 0], $where2);
- $objGroupMsg->updateObject(['is_pin' => 1], $args);
- $objUser = new TableHelper('user_info', 'dw_chat');
- $user = $objUser->getRow(['user_id' => $row['from']]);
- $row = array_merge($row, arrayFilter($user, ['user_name', 'nick_name', 'cover_photo']));
-
- ThirdApi::pushGroupEvent($group_id, [
- 'type' => 'pin_msg',
- 'group_id' => $group_id,
- 'pinMsg' => $row,
- ]);
- return $row;
- }
-
- public function actionUnpinMsg($args) {
- $rules = [
- 'group_id' => ['string', 'desc' => '群id'],
- 'hash' => ['string', 'desc' => '消息hash'],
- ];
- Param::checkParam2($rules, $args);
- $group_id = (int) $args['group_id'];
- $this->_checkGroupAdmin($group_id);
- $objGroupMsg = new TableHelper('group_msg', 'dw_chat');
- $count = $objGroupMsg->getCount($args);
- if (!$count) {
- Response::error(CODE_NORMAL_ERROR, 'can not find the msg');
- }
-
- $objGroupMsg->updateObject(['is_pin' => 0], $args);
-
- ThirdApi::pushGroupEvent($group_id, [
- 'type' => 'unpin_msg',
- 'group_id' => $group_id,
- 'hash' => $args['hash'],
- ]);
- return $args['hash'];
- }
-
- public function actionGetFriends($args) {
- Param::checkParam2([], $args);
- $user_id = User::getUserId();
- $is_group = 0;
- $where = compact('user_id', 'is_group');
- $keyWord = [
- '_field' => 'session_id',
- '_sort' => 'update_time_int DESC',
- '_limit' => 500,
- ];
- $objSession = new Session();
- $session_ids = $objSession->objTable->getCol($where, $keyWord);
- $friend_ids = array_map(function($session_id) use ($user_id) {
- return str_replace(['-', $user_id], ['', ''], $session_id);
- }, $session_ids);
- $objUserInfo = new TableHelper('user_info', 'dw_chat');
- $_field = 'user_id, user_name, nick_name, cover_photo';
- $users = $objUserInfo->getAll(['user_id' => $friend_ids], compact('_field'));
- return $users;
- }
-
- public function actionCreate($args) {
- $rules = [
- 'group_title' => ['string', 'desc' => '群名称'],
- 'cover_photo' => ['string', 'nullable' => true, 'desc' => '群logo'],
- 'user_id_list' => ['string', 'nullable' => true, 'desc' => '好友id列表用,隔开'],
- ];
- Param::checkParam2($rules, $args);
- $creator = User::getUserId();
- $objGroupInfo = new GroupInfo();
- $args['creator'] = $creator;
- $sess = [];
- try {
- $sess = $objGroupInfo->create($args);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- return $sess;
- }
-
- public function actionJoin($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群组id'],
- ];
- Param::checkParam2($rules, $args);
- $userId = User::getUserId();
- try {
- (new GroupInfo())->joinGroup($userId, $args['group_id']);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- }
-
- public function actionLeave($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群组id'],
- ];
- Param::checkParam2($rules, $args);
- $userId = User::getUserId();
- try {
- (new GroupInfo())->leaveGroup($userId, $args['group_id']);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- }
-
- public function actionBlockUser($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群组id'],
- 'block_id' => ['int', 'desc' => '用户id'],
- ];
- Param::checkParam2($rules, $args);
- $group_id = (int) $args['group_id'];
- $user_id = (int) $args['block_id'];
- if ($user_id == TG_BOT_ID) {
- Response::error(CODE_NO_PERMITION, 'can not block TG_BOT');
- }
- $this->_checkGroupAdmin($group_id);
- $objUserGroup = new UserGroup();
- $objUserGroup->setBlock($group_id, $user_id, 1);
- $eventData = [
- 'type' => 'block',
- 'group_id' => $group_id,
- 'from' => User::getUserId(),
- 'to' => $user_id,
- 'timestamp' => Session::getMS(),
- ];
- ThirdApi::pushGroupEvent($group_id, $eventData);
- }
-
- public function actionUnblockUser($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群组id'],
- 'block_id' => ['int', 'desc' => '用户id'],
- ];
- Param::checkParam2($rules, $args);
- $group_id = (int) $args['group_id'];
- $user_id = (int) $args['block_id'];
- $this->_checkGroupAdmin($group_id);
- $objUserGroup = new UserGroup();
- $objUserGroup->setBlock($group_id, $user_id, 0);
- $eventData = [
- 'type' => 'unblock',
- 'group_id' => $group_id,
- 'from' => User::getUserId(),
- 'to' => $user_id,
- 'timestamp' => Session::getMS(),
- ];
- ThirdApi::pushGroupEvent($group_id, $eventData);
- }
- private function _checkGroupAdmin($group_id) {
- $owner = User::getUserId();
- $objUserGroup = new UserGroup();
- if (!$objUserGroup->isAdmin($group_id, $owner)) {
- Response::error(CODE_NO_PERMITION);
- }
- }
-
- public function actionChangeName($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群id'],
- 'name' => ['string', 'reg' => '/^[a-z0-9\.]+/i', 'desc' => '新群名'],
- ];
- Param::checkParam2($rules, $args);
- $objGroup = new GroupInfo();
- $userId = User::getUserId();
- $groupId = (int)$args['group_id'];
- if (is_numeric($args['name'])) {
- Response::error(CODE_PARAM_ERROR, 'name can not be pure numbers');
- }
- $groupInfo = $objGroup->objTable->getRow(['group_id' => $groupId]);
- if (!$groupInfo) {
- Response::error(CODE_PARAM_ERROR, 'group not exists');
- }
-
- if ($groupInfo['group_id'] != $groupInfo['group_name']) {
- Response::error(CODE_PARAM_ERROR, 'only one change group name');
- }
- if ($objGroup->objTable->getRow(['group_name' => $args['name']])) {
- Response::error(CODE_PARAM_ERROR, 'group name exists');
- }
- $data = [
- 'group_name' => htmlentities($args['name']),
- ];
- try {
- $objGroup->setData($userId, $args['group_id'], $data);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- ThirdApi::pushGroupEvent($args['group_id'], [
- 'type' => 'update',
- 'from' => $userId,
- ]);
- }
-
- public function actionChangeNotice($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群id'],
- 'notice' => ['string', 'desc' => '新公告'],
- ];
- Param::checkParam2($rules, $args);
- $objGroup = new GroupInfo();
- $userId = User::getUserId();
- $data = [
- 'group_notice' => htmlentities($args['notice']),
- ];
- try {
- $objGroup->setData($userId, $args['group_id'], $data);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- ThirdApi::pushGroupEvent($args['group_id'], [
- 'type' => 'update',
- 'from' => $userId,
- ]);
- }
-
- public function actionChangeCover($args) {
- $args = array_merge($args, $_FILES);
- $rules = [
- 'group_id' => ['int', 'desc' => '群id'],
- 'cover_photo' => ['array', 'desc' => '头像文件'],
- ];
- Param::checkParam2($rules, $args);
- $file = $args['cover_photo'];
- $cover_photo = '';
- try {
- $cover_photo = (new FileUrl())->getFileUrl($file['tmp_name'], $file['name'], $file['type'], true);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- $objGroup = new GroupInfo();
- $userId = User::getUserId();
- $data = [
- 'cover_photo' => $cover_photo,
- ];
- try {
- $objGroup->setData($userId, $args['group_id'], $data);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- ThirdApi::pushGroupEvent($args['group_id'], [
- 'type' => 'update',
- 'from' => $userId,
- ]);
- }
-
- public function actionChangeTitle($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群id'],
- 'title' => ['string', 'desc' => '新标题'],
- ];
- Param::checkParam2($rules, $args);
- $objGroup = new GroupInfo();
- $userId = User::getUserId();
- $data = [
- 'group_title' => htmlentities($args['title']),
- ];
- try {
- $objGroup->setData($userId, $args['group_id'], $data);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- ThirdApi::pushGroupEvent($args['group_id'], [
- 'type' => 'update',
- 'from' => $userId,
- ]);
- GroupInfo::setGroupNameById($args['group_id'], $data['group_title']);
- }
-
- public function actionInvites($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群id'],
- 'user_ids' => ['string', 'desc' => '用户id 多人,分割'],
- ];
- Param::checkParam2($rules, $args);
- $groupId = (int)$args['group_id'];
- $userIds = array_filter(explode(',', $args['user_ids']), function ($v) {
- return intval($v) > 0;
- });
- $adminId = User::getUserId();
- if (!(new UserGroup())->isAdmin($groupId, $adminId)) {
- Response::error(CODE_NO_PERMITION, 'no permission');
- }
- $count = count($userIds);
- $success = 0;
- $objGroupInfo = new GroupInfo();
- foreach ($userIds as $userId) {
- try {
- $objGroupInfo->joinGroup($userId, $groupId);
- $success += 1;
- } catch (Exception $e) {}
- }
- return compact('count', 'success');
- }
-
- public function actionRemoves($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群id'],
- 'user_ids' => ['string', 'desc' => '用户id 多人,分割'],
- ];
- Param::checkParam2($rules, $args);
- $groupId = (int)$args['group_id'];
- $userIds = array_filter(explode(',', $args['user_ids']), function ($v) {
- return intval($v) > 0;
- });
- $adminId = User::getUserId();
- if (!(new UserGroup())->isAdmin($groupId, $adminId)) {
- Response::error(CODE_NO_PERMITION, 'no permission');
- }
- $count = count($userIds);
- $success = 0;
- $objGroupInfo = new GroupInfo();
- $group = $objGroupInfo->objTable->getRow(['group_id' => $groupId]);
- if (!$group) {
- Response::error(CODE_PARAM_ERROR, 'group not exists');
- }
- foreach ($userIds as $userId) {
- try {
- $objGroupInfo->leaveGroup($userId, $groupId, $group);
- $success += 1;
- } catch (Exception $e) {}
- }
- return compact('count', 'success');
- }
-
- public function actionRepealMsg($args) {
- $rules = [
- 'group_id' => ['string', 'desc' => '群id'],
- 'hash' => ['string', 'desc' => '消息hash'],
- ];
- Param::checkParam2($rules, $args);
- $userId = User::getUserId();
- $objMsg = new GroupMsg();
- try {
- $objMsg->repeal($userId, $args['group_id'], $args['hash']);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- }
-
- public function actionAddAdmin($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群id'],
- 'user_ids' => ['string', 'desc' => '用户id , 分割'],
- ];
- Param::checkParam2($rules, $args);
- $creator = User::getUserId();
- $userIds = array_map('intval', explode(',', $args['user_ids']));
- try {
- (new GroupInfo())->addAdmin($args['group_id'], $creator, $userIds);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- }
-
- public function actionRemoveAdmin($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群id'],
- 'admin_id' => ['int', 'desc' => '管理员id'],
- ];
- Param::checkParam2($rules, $args);
- $creator = User::getUserId();
- try {
- (new GroupInfo())->removeAdmin($args['group_id'], $creator, $args['admin_id']);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- }
-
- public function actionMemberSearch($args) {
- $rules = [
- 'keyword' => ['string', 'desc' => '关键字'],
- 'group_id' => ['int', 'desc' => '群id'],
- ];
- Param::checkParam2($rules, $args);
- return (new GroupInfo())->memberSearch($args['group_id'], $args['keyword']);
- }
-
- public function actionChangeCreator($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群id'],
- 'new_creator' => ['int', 'desc' => '新群主id'],
- ];
- Param::checkParam2($rules, $args);
- $userId = User::getUserId();
- try {
- (new GroupInfo())->changeCreator($args['group_id'], $userId, $args['new_creator']);
- } catch (Exception $e) {
- Response::error($e->getCode(), $e->getMessage());
- }
- }
-
- public function actionHotList($args) {
- $rules = [];
- Param::checkParam2($rules, $args);
- $objGroup = new GroupInfo();
- return $objGroup->getHotList();
- }
- }
|