feat: 添加用户机器人 webhook 事件配置,优化相关逻辑

This commit is contained in:
kuaifan
2025-09-30 04:25:50 +00:00
parent 6ffd169784
commit f59bdaf5e0
8 changed files with 443 additions and 55 deletions

View File

@@ -12,6 +12,7 @@ use App\Module\AI;
use App\Module\Doo;
use App\Models\File;
use App\Models\User;
use App\Models\UserBot;
use App\Module\Base;
use App\Module\Timer;
use App\Models\Setting;
@@ -443,6 +444,29 @@ class DialogController extends AbstractController
return Base::retError('打开会话失败');
}
$data = WebSocketDialog::synthesizeData($dialog->id, $user->userid);
if ($userid > 0) {
$botTarget = User::whereUserid($userid)->whereBot(1)->first();
if ($botTarget) {
$userBot = UserBot::whereBotId($botTarget->userid)->first();
if ($userBot) {
$userBot->dispatchWebhook(UserBot::WEBHOOK_EVENT_DIALOG_OPEN, [
'dialog_id' => $dialog->id,
'dialog_type' => $dialog->type,
'session_id' => $dialog->session_id,
'dialog_name' => $dialog->getGroupName(),
'user' => [
'userid' => $user->userid,
'email' => $user->email,
'nickname' => $user->nickname,
],
], 10, [
'dialog' => $dialog->id,
'operator' => $user->userid,
]);
}
}
}
return Base::retSuccess('success', $data);
}