|
@@ -20,7 +20,7 @@ class TgController extends BaseController {
|
|
|
public function actionWebhook($args) {
|
|
|
$content = file_get_contents("php://input");
|
|
|
$update = json_decode($content, true);
|
|
|
- file_put_contents('/tmp/telegram_message.log', var_export($update, true), FILE_APPEND);
|
|
|
+// file_put_contents('/tmp/telegram_message.log', var_export($update, true), FILE_APPEND);
|
|
|
if (isset($update["message"])) {
|
|
|
try {
|
|
|
Telegram::processMessage($update["message"]);
|
|
@@ -69,7 +69,8 @@ class TgController extends BaseController {
|
|
|
$alreadySync = $objGroup->objTable->getCount(['tg_group_id' => $tgGroupId]);
|
|
|
|
|
|
// 未绑定的群
|
|
|
- $groups = $objGroup->objTable->getAll(['creator' => $userId, 'tg_group_id' => 0], [
|
|
|
+ $groupIds = (new UserGroup())->objTable->getCol(['user_id' => $userId, 'is_admin' => 1, 'state' => UserGroup::STATE_IN_GROUP]);
|
|
|
+ $groups = $objGroup->objTable->getAll(['group_id' => $groupIds, 'tg_group_id' => 0], [
|
|
|
'_field' => 'group_id, group_title, group_name',
|
|
|
'_sortKey' => 'group_id DESC',
|
|
|
]);
|
|
@@ -94,8 +95,8 @@ class TgController extends BaseController {
|
|
|
$tgGroupId = intval($args['tg_group_id']);
|
|
|
$objGroup = new GroupInfo();
|
|
|
|
|
|
- $group = $objGroup->objTable->getRow(['creator' => $userId, 'group_id' => $args['group_id']]);
|
|
|
- if (!$group) {
|
|
|
+
|
|
|
+ if (!(new UserGroup())->isAdmin($args['group_id'], $userId)) {
|
|
|
Response::error(CODE_NO_PERMITION, 'no permission');
|
|
|
}
|
|
|
|
|
@@ -103,6 +104,7 @@ class TgController extends BaseController {
|
|
|
Response::error(CODE_NORMAL_ERROR, 'already sync other group');
|
|
|
}
|
|
|
|
|
|
+ $group = $objGroup->objTable->getRow(['group_id' => $args['group_id']]);
|
|
|
try {
|
|
|
$objGroup->joinGroup(TG_BOT_ID, $args['group_id'], $group);
|
|
|
} catch (Exception $e) {
|