|
|
|
@ -292,89 +292,6 @@ class Message extends BaseModel |
|
|
|
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){ |
|
|
|
$group=Group::find($group_id); |
|
|
|
|