From 0da71389ceb57df61c67753bf10f6a602013d258 Mon Sep 17 00:00:00 2001 From: ASUS <515617283@qq.com> Date: Wed, 3 Dec 2025 15:38:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BC=9A=E8=AF=9D=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chat/controller/MessageController.php | 30 +++++++++++++++++++++++ app/chat/model/ChatMessage.php | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/app/chat/controller/MessageController.php b/app/chat/controller/MessageController.php index 1f9b214..79ef13a 100644 --- a/app/chat/controller/MessageController.php +++ b/app/chat/controller/MessageController.php @@ -188,4 +188,34 @@ class MessageController extends ApiController return $this->success(['list' => ChatMessage::getconverlist($this->uid, $this->user_type)]); } } + + /** + * 删除会话列表 + */ + public function getSessionListDel(Request $request): Response + { + $session_id = $request->post('session_id'); + if(empty($session_id)) { + return $this->error('参数不完整'); + } + $list_json = Redis::get('usermsg:list:' . $this->user_type . ':' . $this->uid); + if($list_json) { + $list_arr = json_decode($list_json, true); + foreach ($list_arr as $k => $list) { + if($list['session_id'] == $session_id) { + unset($list_arr[$k]); + } + } + if(count($list_arr) >= 1) { + Redis::setEx('usermsg:list:' . $this->user_type . ':' . $this->uid, 30 * 86400, json_encode($list_arr)); + }else { + Redis::del('usermsg:list:' . $this->user_type . ':' . $this->uid); + } + } + return $this->success(); + } + + + + } diff --git a/app/chat/model/ChatMessage.php b/app/chat/model/ChatMessage.php index eb7dab8..4d684f3 100644 --- a/app/chat/model/ChatMessage.php +++ b/app/chat/model/ChatMessage.php @@ -42,7 +42,7 @@ class ChatMessage extends BaseModel } $data[$i]['unread_count'] = $unreadCount; - if($session['session_id']) { + if(!empty($session['session_id'])) { // 最后一条消息 $lastMsg = Db::name('chat_message') ->where('session_id', $session['session_id'])