From d149c16713fba4305b647531f3d3cc62e6bd90c0 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Thu, 7 Nov 2024 08:53:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=90=9C=E7=B4=A2=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E6=8A=A5=E9=94=99=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/DialogController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/DialogController.php b/app/Http/Controllers/Api/DialogController.php index c94c853de..b5e1ecbde 100755 --- a/app/Http/Controllers/Api/DialogController.php +++ b/app/Http/Controllers/Api/DialogController.php @@ -164,12 +164,17 @@ class DialogController extends AbstractController // 搜索消息会话 if (count($list) < 20) { $prefix = DB::getTablePrefix(); + if (preg_match('/[+\-><()~*"@]/', $key)) { + $against = "\"{$key}\""; + } else { + $against = "*{$key}*"; + } $msgs = DB::table('web_socket_dialog_users as u') ->select(['d.*', 'u.top_at', 'u.last_at', 'u.mark_unread', 'u.silence', 'u.hide', 'u.color', 'u.updated_at as user_at', 'm.id as search_msg_id']) ->join('web_socket_dialogs as d', 'u.dialog_id', '=', 'd.id') ->join('web_socket_dialog_msgs as m', 'm.dialog_id', '=', 'd.id') ->where('u.userid', $user->userid) - ->whereRaw("MATCH({$prefix}m.key) AGAINST('*{$key}*' IN BOOLEAN MODE)") + ->whereRaw("MATCH({$prefix}m.key) AGAINST('{$against}' IN BOOLEAN MODE)") ->orderByDesc('m.id') ->take(20 - count($list)) ->get()