|
@@ -160,27 +160,25 @@ class Message extends BaseModel
|
|
|
$param['content'] = Config::where('field','reply_keyword_math_fail')->value('val');
|
|
$param['content'] = Config::where('field','reply_keyword_math_fail')->value('val');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $fromUserId = $param['toContactId'];
|
|
|
|
|
- $param['toContactId'] = $param['fromUser']['id'];
|
|
|
|
|
|
|
+ $fromUserId = (int)$param['toContactId'];
|
|
|
|
|
+ $user_id = (int)$param['user_id'];
|
|
|
|
|
+ $param['toContactId'] = $user_id;
|
|
|
$param['user_id'] = $fromUserId;
|
|
$param['user_id'] = $fromUserId;
|
|
|
- $param['fromUser'] = [
|
|
|
|
|
- 'id' => $fromUserId,
|
|
|
|
|
- 'displayName' => '88888',
|
|
|
|
|
- 'avatar' => '',
|
|
|
|
|
- 'account' => 'admin',
|
|
|
|
|
- ];
|
|
|
|
|
- $param['content'] = Config::where('field','reply_keyword_math_fail')->value('val');
|
|
|
|
|
- //$data2 = self::sendMsg($param,$is_group, 0, $param['user_id']);
|
|
|
|
|
|
|
+ $param['fromUser'] = null;
|
|
|
|
|
+ $param['id'] = \utils\Str::getUuid();
|
|
|
|
|
+
|
|
|
|
|
+ self::sendMsg($param,$is_group, 0, $user_id);
|
|
|
|
|
|
|
|
//机器人自动回复消息
|
|
//机器人自动回复消息
|
|
|
- event('AutoReplyMessage', ['param' => $param, 'globalConfig' => $globalConfig]);
|
|
|
|
|
|
|
+ //event('AutoReplyMessage', ['param' => $param, 'globalConfig' => $globalConfig]);
|
|
|
}
|
|
}
|
|
|
return $data;
|
|
return $data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//实际发送消息
|
|
//实际发送消息
|
|
|
public static function sendMsg($param,$is_group=0,$is_sys=0, $uid=0){
|
|
public static function sendMsg($param,$is_group=0,$is_sys=0, $uid=0){
|
|
|
- $uid = $uid ?: ($param['user_id'] ?? 1);
|
|
|
|
|
|
|
+ // $uid = $uid ?: ($param['user_id'] ?? 1);
|
|
|
|
|
+ $uid = self::$uid ?: ($param['user_id'] ?? 1);
|
|
|
$toContactId=$param['toContactId'];
|
|
$toContactId=$param['toContactId'];
|
|
|
$manage=[];
|
|
$manage=[];
|
|
|
// 重新建立会话,更新会话删除记录
|
|
// 重新建立会话,更新会话删除记录
|
|
@@ -243,7 +241,7 @@ class Message extends BaseModel
|
|
|
$sendData['at']=$atList;
|
|
$sendData['at']=$atList;
|
|
|
$sendData['msg_id']=$message->msg_id;
|
|
$sendData['msg_id']=$message->msg_id;
|
|
|
$sendData['is_read']=0;
|
|
$sendData['is_read']=0;
|
|
|
- $sendData['to_user']=$toContactId;
|
|
|
|
|
|
|
+ $sendData['to_user']=(string)$toContactId;
|
|
|
$sendData['role']=$manage[self::$uid] ?? 3;
|
|
$sendData['role']=$manage[self::$uid] ?? 3;
|
|
|
$sendData['sendTime']=(int)$sendData['sendTime'];
|
|
$sendData['sendTime']=(int)$sendData['sendTime'];
|
|
|
//这里单聊中发送对方的消息,对方是接受状态,自己是对方的联系人,要把发送对象设置为发送者的ID。
|
|
//这里单聊中发送对方的消息,对方是接受状态,自己是对方的联系人,要把发送对象设置为发送者的ID。
|
|
@@ -252,9 +250,9 @@ class Message extends BaseModel
|
|
|
// 将团队所有成员的未读状态+1
|
|
// 将团队所有成员的未读状态+1
|
|
|
GroupUser::editGroupUser([['group_id','=',$toContactId],['user_id','<>',$uid]],['unread'=>Db::raw('unread+1')]);
|
|
GroupUser::editGroupUser([['group_id','=',$toContactId],['user_id','<>',$uid]],['unread'=>Db::raw('unread+1')]);
|
|
|
}else{
|
|
}else{
|
|
|
- $sendData['toContactId']=$toContactId;//$uid;
|
|
|
|
|
|
|
+ //$sendData['toContactId']=$toContactId;//$uid;
|
|
|
|
|
+ $sendData['toContactId'] = $param['user_id'];
|
|
|
}
|
|
}
|
|
|
- $sendData['fromUser']['id']=(int)$sendData['fromUser']['id'];
|
|
|
|
|
$sendData['fileSize']=$fileSzie;
|
|
$sendData['fileSize']=$fileSzie;
|
|
|
$sendData['fileName']=$fileName;
|
|
$sendData['fileName']=$fileName;
|
|
|
if(in_array($sendData['type'],self::$fileType)){
|
|
if(in_array($sendData['type'],self::$fileType)){
|
|
@@ -276,11 +274,20 @@ class Message extends BaseModel
|
|
|
$toContactId=[$toContactId,$param['user_id']];
|
|
$toContactId=[$toContactId,$param['user_id']];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $sendData['toUser']=$param['toContactId'];
|
|
|
|
|
|
|
+ $sendData['toUser']=(string)$param['toContactId'];
|
|
|
$user=new User();
|
|
$user=new User();
|
|
|
// 将聊天窗口的联系人信息带上,方便临时会话
|
|
// 将聊天窗口的联系人信息带上,方便临时会话
|
|
|
|
|
|
|
|
$sendData['contactInfo']=$user->setContact($forContactId,$is_group,$sendData['type'],$sendData['content']);
|
|
$sendData['contactInfo']=$user->setContact($forContactId,$is_group,$sendData['type'],$sendData['content']);
|
|
|
|
|
+ if (empty($sendData['fromUser'])) {
|
|
|
|
|
+ $sendData['fromUser'] = [
|
|
|
|
|
+ 'id' => $sendData['contactInfo']['id'],
|
|
|
|
|
+ 'displayName' => $sendData['contactInfo']['displayName'],
|
|
|
|
|
+ 'avatar' => $sendData['contactInfo']['avatar'],
|
|
|
|
|
+ 'account' => '',
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ $sendData['fromUser']['id']=(int)$sendData['fromUser']['id'];
|
|
|
// 向发送方发送消息
|
|
// 向发送方发送消息
|
|
|
wsSendMsg($toContactId,$type,$sendData,$is_group);
|
|
wsSendMsg($toContactId,$type,$sendData,$is_group);
|
|
|
$sendData['toContactId']=$param['toContactId'];
|
|
$sendData['toContactId']=$param['toContactId'];
|