优化代码

main
gzydong 2021-07-23 22:52:14 +08:00
parent 057371d9a1
commit badfda6852
1 changed files with 13 additions and 13 deletions

View File

@ -82,19 +82,19 @@ class TalkService extends BaseService
$rows = $rowsSqlObj->orderBy('talk_records.id', 'desc')->limit($limit)->get()->toArray(); $rows = $rowsSqlObj->orderBy('talk_records.id', 'desc')->limit($limit)->get()->toArray();
if ($record_id === 0 && $talk_type == TalkModeConstant::PRIVATE_CHAT) { //if ($record_id === 0 && $talk_type == TalkModeConstant::PRIVATE_CHAT) {
if (!di()->get(UserFriendService::class)->isFriend($user_id, $receiver_id, true)) { // if (!di()->get(UserFriendService::class)->isFriend($user_id, $receiver_id, true)) {
array_unshift($rows, [ // array_unshift($rows, [
'id' => ($rows[0]['id'] ?? 0) + 1, // 'id' => ($rows[0]['id'] ?? 0) + 1,
'talk_type' => TalkModeConstant::PRIVATE_CHAT, // 'talk_type' => TalkModeConstant::PRIVATE_CHAT,
'msg_type' => TalkMessageType::SYSTEM_TEXT_MESSAGE, // 'msg_type' => TalkMessageType::SYSTEM_TEXT_MESSAGE,
'user_id' => 0, // 'user_id' => 0,
'receiver_id' => $user_id, // 'receiver_id' => $user_id,
'content' => '你与对方已解除好友关系,系统已禁止发送消息!', // 'content' => '你与对方已解除好友关系,系统已禁止发送消息!',
'created_at' => date('Y-m-d H:i:s'), // 'created_at' => date('Y-m-d H:i:s'),
]); // ]);
} // }
} //}
return di()->get(FormatMessageService::class)->handleChatRecords($rows); return di()->get(FormatMessageService::class)->handleChatRecords($rows);
} }