删除会话列表
This commit is contained in:
@@ -188,4 +188,34 @@ class MessageController extends ApiController
|
|||||||
return $this->success(['list' => ChatMessage::getconverlist($this->uid, $this->user_type)]);
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class ChatMessage extends BaseModel
|
|||||||
}
|
}
|
||||||
$data[$i]['unread_count'] = $unreadCount;
|
$data[$i]['unread_count'] = $unreadCount;
|
||||||
|
|
||||||
if($session['session_id']) {
|
if(!empty($session['session_id'])) {
|
||||||
// 最后一条消息
|
// 最后一条消息
|
||||||
$lastMsg = Db::name('chat_message')
|
$lastMsg = Db::name('chat_message')
|
||||||
->where('session_id', $session['session_id'])
|
->where('session_id', $session['session_id'])
|
||||||
|
|||||||
Reference in New Issue
Block a user