diff --git a/app/enterprise/model/Message.php b/app/enterprise/model/Message.php index 49f8955..9b8fc7d 100644 --- a/app/enterprise/model/Message.php +++ b/app/enterprise/model/Message.php @@ -20,6 +20,8 @@ class Message extends BaseModel protected $json = ["extends"]; protected $jsonAssoc = true; protected static $fileType=['file','image','video','voice','emoji']; + // 判断是否为拉黑发送的数据 + protected $blackData = false; // 添加聊天记录 public static function addData($data){ @@ -146,23 +148,15 @@ class Message extends BaseModel } // 判断是否存在及数据有效性 if (isset($param['msg_id']) && is_numeric($param['msg_id'])) { - $where = [ - 'msg_id' => $param['msg_id'], - 'status' => 2, - 'from_user' => $uid, - 'to_user' => $param['toContactId'], - ]; + $where = ['msg_id' => $param['msg_id'], 'status' => 2]; $message = $this->where($where)->find(); - if (!$message) { - $this->error = lang('system.error'); - return false; - } + if ($message) $this->blackData = true; } - return self::sendMsg($param,$is_group); + return self::sendMsg($param,$is_group,$this->blackData); } //实际发送消息 - public static function sendMsg($param,$is_group=0){ + public static function sendMsg($param,$is_group=0,$blackData=false){ $uid=self::$uid ?: ($param['user_id'] ?? 1); $toContactId=$param['toContactId']; $manage=[]; @@ -232,7 +226,7 @@ class Message extends BaseModel } $message=new self(); $message->update(['is_last'=>0],['chat_identify'=>$chat_identify]); - if (isset($param['msg_id'])) { + if (isset($param['msg_id']) && $blackData) { $message = $message->where('msg_id', $param['msg_id'])->find(); if (!$message) { $message=new self();