|
|
|
@ -110,12 +110,10 @@ class Message extends BaseModel |
|
|
|
return false; |
|
|
|
} |
|
|
|
if ($friend['is_blacklist'] == 1) { |
|
|
|
$this->error=lang('im.youBlacklist'); |
|
|
|
return false; |
|
|
|
$param['del_user'] = $param['toContactId']; |
|
|
|
} |
|
|
|
if ($otherFriend['is_blacklist'] == 1) { |
|
|
|
$this->error=lang('im.meBlacklist'); |
|
|
|
return false; |
|
|
|
$param['del_user'] = $param['toContactId']; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -211,6 +209,10 @@ class Message extends BaseModel |
|
|
|
$param['poster']=$data['poster']; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isset($param['del_user']) && $param['del_user']) { |
|
|
|
$data['del_user'] = $param['del_user']; |
|
|
|
$data['status'] = 2; |
|
|
|
} |
|
|
|
$message=new self(); |
|
|
|
$message->update(['is_last'=>0],['chat_identify'=>$chat_identify]); |
|
|
|
$message->save($data); |
|
|
|
@ -219,6 +221,9 @@ class Message extends BaseModel |
|
|
|
$type=$is_group?'group':'simple'; |
|
|
|
$sendData=$param; |
|
|
|
$sendData['status']='succeed'; |
|
|
|
if (isset($data['status']) && $data['status'] == 2) { |
|
|
|
$sendData['status']='failed'; |
|
|
|
} |
|
|
|
$sendData['at']=$atList; |
|
|
|
$sendData['msg_id']=$message->msg_id; |
|
|
|
$sendData['is_read']=0; |
|
|
|
@ -248,7 +253,11 @@ class Message extends BaseModel |
|
|
|
$sendData['download']= $sendData['file_id'] ? getMainHost().'/filedown/'.encryptIds($sendData['file_id']) : ''; |
|
|
|
} |
|
|
|
if($is_group==0){ |
|
|
|
if ($sendData['status'] == 'succeed') { |
|
|
|
$toContactId=[$toContactId,$param['user_id']]; |
|
|
|
} else { |
|
|
|
$toContactId=[$param['user_id']]; |
|
|
|
} |
|
|
|
} |
|
|
|
$sendData['toUser']=$param['toContactId']; |
|
|
|
$user=new User(); |
|
|
|
@ -258,7 +267,90 @@ class Message extends BaseModel |
|
|
|
wsSendMsg($toContactId,$type,$sendData,$is_group); |
|
|
|
$sendData['toContactId']=$param['toContactId']; |
|
|
|
return $sendData; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 被拉黑重新发送 |
|
|
|
public function againSendMessage($param) |
|
|
|
{ |
|
|
|
$msg_id = $param['msg_id']; |
|
|
|
$toContactId = $param['toContactId']; |
|
|
|
$uid = $param['user_id']; |
|
|
|
// 验证是否是好友 |
|
|
|
$friend = Friend::where(['friend_user_id' => $uid, 'create_user' => $toContactId])->find(); |
|
|
|
if (!$friend) { |
|
|
|
$this->error=lang('im.notFriend'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
$otherFriend = Friend::where(['friend_user_id' => $toContactId, 'create_user' => $uid])->find(); |
|
|
|
if (!$otherFriend) { |
|
|
|
$this->error=lang('im.friendNot'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
// 判断是否拉黑 |
|
|
|
if ($friend['is_blacklist'] == 1) { |
|
|
|
$this->error=lang('im.youBlacklist'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
if ($otherFriend['is_blacklist'] == 1) { |
|
|
|
$this->error=lang('im.meBlacklist'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
$where = [ |
|
|
|
'msg_id' => $msg_id, |
|
|
|
'to_user' => $toContactId, |
|
|
|
'from_user' => $uid, |
|
|
|
'status' => 2 |
|
|
|
]; |
|
|
|
$message = Message::where($where)->find(); |
|
|
|
if (!$message) { |
|
|
|
$this->error=lang('system.error'); |
|
|
|
return false; |
|
|
|
} |
|
|
|
$message->status = 1; |
|
|
|
$message->del_user = ''; |
|
|
|
$message->save(); |
|
|
|
|
|
|
|
// 拼接消息推送 |
|
|
|
$is_group = 0; |
|
|
|
$type='simple'; |
|
|
|
$sendData=$param; |
|
|
|
$sendData['status']='succeed'; |
|
|
|
if (isset($data['status']) && $data['status'] == 2) { |
|
|
|
$sendData['status']='failed'; |
|
|
|
} |
|
|
|
$sendData['at']=[]; |
|
|
|
$sendData['msg_id']=$message->msg_id; |
|
|
|
$sendData['is_read']=0; |
|
|
|
$sendData['to_user']=$toContactId; |
|
|
|
$sendData['role']=$manage[self::$uid] ?? 3; |
|
|
|
$sendData['sendTime']=(int)$sendData['sendTime']; |
|
|
|
//这里单聊中发送对方的消息,对方是接受状态,自己是对方的联系人,要把发送对象设置为发送者的ID。 |
|
|
|
$sendData['toContactId']=$uid; |
|
|
|
|
|
|
|
$sendData['fromUser']['id']=(int)$sendData['fromUser']['id']; |
|
|
|
$sendData['fileSize']=isset($param['file_size'])?$param['file_size']:''; |
|
|
|
$sendData['fileName']=isset($param['file_name'])?$param['file_name']:''; |
|
|
|
if(in_array($sendData['type'],self::$fileType)){ |
|
|
|
$sendData['content']=getFileUrl($sendData['content']); |
|
|
|
if($sendData['type']=='image'){ |
|
|
|
$pre=1; |
|
|
|
}else{ |
|
|
|
$pre=2; |
|
|
|
} |
|
|
|
$sendData['preview']=previewUrl($sendData['content'],$pre); |
|
|
|
$sendData['extUrl']=getExtUrl($sendData['content']); |
|
|
|
$sendData['download']= $sendData['file_id'] ? getMainHost().'/filedown/'.encryptIds($sendData['file_id']) : ''; |
|
|
|
} |
|
|
|
$toContactId=[$toContactId,$param['user_id']]; |
|
|
|
$sendData['toUser']=$param['toContactId']; |
|
|
|
$user=new User(); |
|
|
|
// 将聊天窗口的联系人信息带上,方便临时会话 |
|
|
|
$sendData['contactInfo']=$user->setContact($sendData['toContactId'],$is_group,$sendData['type'],$sendData['content']); |
|
|
|
// 向发送方发送消息 |
|
|
|
wsSendMsg($toContactId,$type,$sendData,$is_group); |
|
|
|
$sendData['toContactId']=$param['toContactId']; |
|
|
|
return $sendData; |
|
|
|
} |
|
|
|
|
|
|
|
// 群禁言 |
|
|
|
public static function nospeak($group_id,$user_id){ |
|
|
|
|