优化代码
parent
2d110bad77
commit
146a9c4993
|
@ -378,9 +378,9 @@ class ChatMessageConsumer extends ConsumerMessage
|
||||||
private function formatTalkMessage(array $data): array
|
private function formatTalkMessage(array $data): array
|
||||||
{
|
{
|
||||||
$message = [
|
$message = [
|
||||||
"id" => 0,// 消息记录ID
|
"id" => 0, // 消息记录ID
|
||||||
"source" => 1,// 消息来源[1:好友私信;2:群聊]
|
"source" => 1, // 消息来源[1:好友私信;2:群聊]
|
||||||
"msg_type" => 1,
|
"msg_type" => 1, // 消息类型
|
||||||
"user_id" => 0, // 发送者用户ID
|
"user_id" => 0, // 发送者用户ID
|
||||||
"receive_id" => 0, // 接收者ID[好友ID或群ID]
|
"receive_id" => 0, // 接收者ID[好友ID或群ID]
|
||||||
"content" => '',// 文本消息
|
"content" => '',// 文本消息
|
||||||
|
|
|
@ -25,9 +25,6 @@ use Hyperf\Redis\Redis;
|
||||||
*/
|
*/
|
||||||
class ServerStart extends ServerStartCallback
|
class ServerStart extends ServerStartCallback
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* 回调事件
|
|
||||||
*/
|
|
||||||
public function beforeStart()
|
public function beforeStart()
|
||||||
{
|
{
|
||||||
stdout_log()->info(sprintf('服务运行ID : %s', SERVER_RUN_ID));
|
stdout_log()->info(sprintf('服务运行ID : %s', SERVER_RUN_ID));
|
||||||
|
|
|
@ -129,12 +129,14 @@ class TalkController extends CController
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($result['type'] == 1) {
|
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['name'] = $userInfo->nickname;
|
||||||
$data['avatar'] = $userInfo->avatar;
|
$data['avatar'] = $userInfo->avatar;
|
||||||
|
$data['unread_num'] = $this->unreadTalkCache->get($user_id, $result['friend_id']);
|
||||||
} else if ($result['type'] == 2) {
|
} 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['name'] = $groupInfo->group_name;
|
||||||
$data['avatar'] = $groupInfo->avatar;
|
$data['avatar'] = $groupInfo->avatar;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue