From 146a9c49937eaed52bfd1857c91cb779c087b08a Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Tue, 20 Apr 2021 19:59:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Amqp/Consumer/ChatMessageConsumer.php | 6 +++--- app/Bootstrap/ServerStart.php | 3 --- app/Controller/Api/V1/TalkController.php | 8 +++++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/Amqp/Consumer/ChatMessageConsumer.php b/app/Amqp/Consumer/ChatMessageConsumer.php index c8274fc..88a90b1 100644 --- a/app/Amqp/Consumer/ChatMessageConsumer.php +++ b/app/Amqp/Consumer/ChatMessageConsumer.php @@ -378,9 +378,9 @@ class ChatMessageConsumer extends ConsumerMessage private function formatTalkMessage(array $data): array { $message = [ - "id" => 0,// 消息记录ID - "source" => 1,// 消息来源[1:好友私信;2:群聊] - "msg_type" => 1, + "id" => 0, // 消息记录ID + "source" => 1, // 消息来源[1:好友私信;2:群聊] + "msg_type" => 1, // 消息类型 "user_id" => 0, // 发送者用户ID "receive_id" => 0, // 接收者ID[好友ID或群ID] "content" => '',// 文本消息 diff --git a/app/Bootstrap/ServerStart.php b/app/Bootstrap/ServerStart.php index 4a42973..7d6d9f2 100644 --- a/app/Bootstrap/ServerStart.php +++ b/app/Bootstrap/ServerStart.php @@ -25,9 +25,6 @@ use Hyperf\Redis\Redis; */ class ServerStart extends ServerStartCallback { - /** - * 回调事件 - */ public function beforeStart() { stdout_log()->info(sprintf('服务运行ID : %s', SERVER_RUN_ID)); diff --git a/app/Controller/Api/V1/TalkController.php b/app/Controller/Api/V1/TalkController.php index f6b776a..3900e73 100644 --- a/app/Controller/Api/V1/TalkController.php +++ b/app/Controller/Api/V1/TalkController.php @@ -129,12 +129,14 @@ class TalkController extends CController ]; if ($result['type'] == 1) { - $data['unread_num'] = $this->unreadTalkCache->get($user_id, $result['friend_id']); - $userInfo = User::where('id', $user_id)->first(['nickname', 'avatar']); + $userInfo = User::where('id', $user_id)->first(['nickname', 'avatar']); + $data['name'] = $userInfo->nickname; $data['avatar'] = $userInfo->avatar; + $data['unread_num'] = $this->unreadTalkCache->get($user_id, $result['friend_id']); } else if ($result['type'] == 2) { - $groupInfo = Group::where('id', $result['group_id'])->first(['group_name', 'avatar']); + $groupInfo = Group::where('id', $result['group_id'])->first(['group_name', 'avatar']); + $data['name'] = $groupInfo->group_name; $data['avatar'] = $groupInfo->avatar; }