Skip to content

Commit 471735b

Browse files
committed
优化聊天系统
1 parent a627056 commit 471735b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

app/Controller/Laboratory/FriendController.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use App\Model\Auth\User;
99
use App\Model\Laboratory\FriendChatHistory;
1010
use App\Model\Laboratory\FriendRelation;
11+
use App\Service\Laboratory\MessageService;
1112
use Hyperf\HttpServer\Annotation\Controller;
1213
use Hyperf\HttpServer\Annotation\Middleware;
1314
use Hyperf\HttpServer\Annotation\Middlewares;
@@ -70,7 +71,7 @@ public function historyMessage()
7071
$friendRemark = FriendRelation::query()->where('uid', $value['to_uid'])->where('friend_id', $value['from_uid'])->value('friend_remark');
7172
if (!empty($friendRemark) && $value['from_uid'] != $userInfo['id']) $displayName = $friendRemark;
7273

73-
$list[] = [
74+
$temp = [
7475
'id' => $value['message_id'],
7576
'status' => $value['status'],
7677
'type' => $value['type'],
@@ -81,7 +82,15 @@ public function historyMessage()
8182
'content' => $value['content'],
8283
'avatar' => $user['avatar'],
8384
'displayName' => $displayName,
85+
'fromUser' => [
86+
'id' => $user['id'],
87+
'avatar' => $user['avatar'] ?? '',
88+
'displayName' => $displayName,
89+
],
8490
];
91+
if ($temp['type'] == FriendChatHistory::FRIEND_CHAT_MESSAGE_TYPE_FORWARD)
92+
$temp['content'] = MessageService::getInstance()->formatForwardMessage($temp['content'], $temp['fromUser']);
93+
$list[] = $temp;
8594
}
8695
return $this->success([
8796
'list' => $list,

app/Controller/Laboratory/Ws/FriendController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ public function pullMessage()
8787
->where('to_uid', $contactData['user_id'])
8888
->where('from_uid', $contactData['contact_id'])
8989
->update(['reception_state' => FriendChatHistory::RECEPTION_STATE_YES]);
90-
9190
$list = [];
9291
foreach ($messageList as $key => $value) {
9392
//获取用户联系人

0 commit comments

Comments
 (0)