添加系统提示消息
parent
4620dbc52d
commit
057371d9a1
|
@ -9,6 +9,7 @@ namespace App\Constants;
|
|||
*/
|
||||
class TalkMessageType
|
||||
{
|
||||
const SYSTEM_TEXT_MESSAGE = 0; //系统文本消息
|
||||
const TEXT_MESSAGE = 1; //文本消息
|
||||
const FILE_MESSAGE = 2; //文件消息
|
||||
const FORWARD_MESSAGE = 3; //会话消息
|
||||
|
|
|
@ -81,6 +81,21 @@ class TalkService extends BaseService
|
|||
});
|
||||
|
||||
$rows = $rowsSqlObj->orderBy('talk_records.id', 'desc')->limit($limit)->get()->toArray();
|
||||
|
||||
if ($record_id === 0 && $talk_type == TalkModeConstant::PRIVATE_CHAT) {
|
||||
if (!di()->get(UserFriendService::class)->isFriend($user_id, $receiver_id, true)) {
|
||||
array_unshift($rows, [
|
||||
'id' => ($rows[0]['id'] ?? 0) + 1,
|
||||
'talk_type' => TalkModeConstant::PRIVATE_CHAT,
|
||||
'msg_type' => TalkMessageType::SYSTEM_TEXT_MESSAGE,
|
||||
'user_id' => 0,
|
||||
'receiver_id' => $user_id,
|
||||
'content' => '你与对方已解除好友关系,系统已禁止发送消息!',
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return di()->get(FormatMessageService::class)->handleChatRecords($rows);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ class UserFriendService
|
|||
public function isFriend(int $user_id, int $friend_id, $is_mutual = false)
|
||||
{
|
||||
$isTrue1 = UsersFriend::where('user_id', $user_id)->where('friend_id', $friend_id)->where('status', 1)->exists();
|
||||
|
||||
if ($is_mutual === false) {
|
||||
return $isTrue1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue