no message

This commit is contained in:
kuaifan 2025-04-24 09:11:41 +08:00
parent eccb3e2825
commit ad7b0cd834
3 changed files with 51 additions and 56 deletions

View File

@ -8,8 +8,6 @@ use Request;
use Redirect;
use Response;
use App\Models\File;
use App\Models\User;
use App\Models\UserTransfer;
use App\Module\Doo;
use App\Module\Base;
use App\Module\Extranet;
@ -502,43 +500,4 @@ class IndexController extends InvokeController
$redirectUrl = Base::fillUrl("fileview/onlinePreview?url=" . urlencode(base64_encode($url)));
return Redirect::to($redirectUrl, 301);
}
/**
* 修复操作离职后续操作(todo 临时,后期删除)
* @return array
*/
public function migration__userdialog()
{
if (Request::header('app-key') !== env('APP_KEY')) {
return Base::retError("key error");
}
go(function() {
Coroutine::sleep(3);
$handled = [];
UserTransfer::orderBy('id')->chunkById(10, function ($transfers) use ($handled) {
/** @var UserTransfer $transfer */
foreach ($transfers as $transfer) {
if (in_array($transfer->original_userid, $handled)) {
continue;
}
$handled[] = $transfer->original_userid;
//
$user = User::find($transfer->original_userid);
if ($user?->isDisable()) {
$transfer->exitDialog();
}
}
});
});
return Base::retSuccess('success');
}
/**
* 保存配置 (todo 已废弃)
* @return string
*/
public function storage__synch()
{
return '<!-- Deprecated -->';
}
}

View File

@ -3,8 +3,8 @@
namespace App\Models;
use App\Module\Base;
use App\Module\Extranet;
use Swoole\Coroutine;
use App\Tasks\UpdateSessionTitleViaAiTask;
use Hhxsv5\LaravelS\Swoole\Task\Task;
use Cache;
/**
@ -82,18 +82,6 @@ class WebSocketDialogSession extends AbstractModel
$session->title = $title;
$session->save();
Cache::forever($cacheKey, true);
// 通过AI接口更新对话标题
go(function () use ($session, $title, $originalTitle) {
Coroutine::sleep(0.1);
$res = Extranet::openAIGenerateTitle($originalTitle);
if (Base::isError($res)) {
return;
}
$newTitle = $res['data'];
if ($newTitle && $newTitle != $title) {
$session->title = Base::cutStr($newTitle, 100);
$session->save();
}
});
Task::deliver(new UpdateSessionTitleViaAiTask($session->id, $originalTitle));
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace App\Tasks;
use App\Models\WebSocketDialogSession;
use App\Module\Base;
use App\Module\Extranet;
/**
* 通过AI接口更新对话标题
*/
class UpdateSessionTitleViaAiTask extends AbstractTask
{
public function __construct($sessionId, $msgText)
{
parent::__construct();
$this->sessionId = $sessionId;
$this->msgText = $msgText;
}
public function start()
{
if (empty($this->sessionId) || empty($this->msgText)) {
return;
}
$session = WebSocketDialogSession::whereId($this->sessionId)->first();
if (!$session) {
return;
}
$res = Extranet::openAIGenerateTitle($this->msgText);
if (Base::isError($res)) {
return;
}
$newTitle = $res['data'];
if ($newTitle && $newTitle != $session->title) {
$session->title = Base::cutStr($newTitle, 100);
$session->save();
}
}
public function end()
{
}
}