初始化
parent
1905a605fa
commit
ffb0a0dd44
|
@ -35,10 +35,10 @@ IP_ADDRESS=0.0.0.0
|
||||||
MAIL_DRIVER=smtp
|
MAIL_DRIVER=smtp
|
||||||
MAIL_HOST=smtp.163.com
|
MAIL_HOST=smtp.163.com
|
||||||
MAIL_PORT=465
|
MAIL_PORT=465
|
||||||
MAIL_USERNAME=18798276809@163.com
|
MAIL_USERNAME=xxxxx
|
||||||
MAIL_PASSWORD=RYD18798276809
|
MAIL_PASSWORD=xxxx
|
||||||
MAIL_FROM_ADDRESS=18798276809@163.com
|
MAIL_FROM_ADDRESS=xxxx@163.com
|
||||||
MAIL_FROM_NAME="Lumen IM 在线聊天"
|
MAIL_FROM_NAME="xxxxx"
|
||||||
MAIL_ENCRYPTION=ssl
|
MAIL_ENCRYPTION=ssl
|
||||||
|
|
||||||
# ---- Rabbit MQ 配置 ----
|
# ---- Rabbit MQ 配置 ----
|
||||||
|
|
|
@ -201,7 +201,7 @@ class ChatMessageConsumer extends ConsumerMessage
|
||||||
$invite = [
|
$invite = [
|
||||||
'type' => $notifyInfo->type,
|
'type' => $notifyInfo->type,
|
||||||
'operate_user' => ['id' => $userInfo->id, 'nickname' => $userInfo->nickname],
|
'operate_user' => ['id' => $userInfo->id, 'nickname' => $userInfo->nickname],
|
||||||
'users' => User::select('id', 'nickname')->whereIn('id', parse_ids($notifyInfo->user_ids))->get()->toArray()
|
'users' => User::whereIn('id', parse_ids($notifyInfo->user_ids))->get(['id', 'nickname'])->toArray()
|
||||||
];
|
];
|
||||||
|
|
||||||
unset($notifyInfo, $userInfo);
|
unset($notifyInfo, $userInfo);
|
||||||
|
@ -212,7 +212,7 @@ class ChatMessageConsumer extends ConsumerMessage
|
||||||
$forwardInfo = ChatRecordsForward::where('record_id', $result->id)->first(['records_id', 'text']);
|
$forwardInfo = ChatRecordsForward::where('record_id', $result->id)->first(['records_id', 'text']);
|
||||||
if ($forwardInfo) {
|
if ($forwardInfo) {
|
||||||
$forward = [
|
$forward = [
|
||||||
'num' => substr_count($forwardInfo->records_id, ',') + 1,
|
'num' => count(parse_ids($forwardInfo->records_id)),
|
||||||
'list' => json_decode($forwardInfo->text, true) ?? []
|
'list' => json_decode($forwardInfo->text, true) ?? []
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,7 @@ class ChatMessageConsumer extends ConsumerMessage
|
||||||
* @param array $data 对话的消息
|
* @param array $data 对话的消息
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function formatTalkMessage(array $data)
|
private function formatTalkMessage(array $data): array
|
||||||
{
|
{
|
||||||
$message = [
|
$message = [
|
||||||
"id" => 0,//消息记录ID
|
"id" => 0,//消息记录ID
|
||||||
|
|
|
@ -93,16 +93,27 @@ SQL;
|
||||||
*
|
*
|
||||||
* @param int $user_id1 用户1
|
* @param int $user_id1 用户1
|
||||||
* @param int $user_id2 用户2
|
* @param int $user_id2 用户2
|
||||||
|
* @param bool $cache 是否读取缓存
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isFriend(int $user_id1, int $user_id2)
|
public static function isFriend(int $user_id1, int $user_id2, bool $cache = false)
|
||||||
{
|
{
|
||||||
// 比较大小交换位置
|
// 比较大小交换位置
|
||||||
if ($user_id1 > $user_id2) {
|
if ($user_id1 > $user_id2) {
|
||||||
[$user_id1, $user_id2] = [$user_id2, $user_id1];
|
[$user_id1, $user_id2] = [$user_id2, $user_id1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::where('user1', $user_id1)->where('user2', $user_id2)->where('status', 1)->exists();
|
$cacheKey = "good_friends:{$user_id1}_$user_id2";
|
||||||
|
if ($cache && redis()->get($cacheKey)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$isTrue = self::where('user1', $user_id1)->where('user2', $user_id2)->where('status', 1)->exists();
|
||||||
|
if ($isTrue) {
|
||||||
|
redis()->setex($cacheKey, 60 * 5, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $isTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,7 +57,7 @@ class MessageHandleService
|
||||||
//验证发送消息用户与接受消息用户之间是否存在好友或群聊关系(后期走缓存)
|
//验证发送消息用户与接受消息用户之间是否存在好友或群聊关系(后期走缓存)
|
||||||
if ($data['source_type'] == 1) {//私信
|
if ($data['source_type'] == 1) {//私信
|
||||||
//判断发送者和接受者是否是好友关系
|
//判断发送者和接受者是否是好友关系
|
||||||
if (!UsersFriend::isFriend(intval($data['send_user']), intval($data['receive_user']))) {
|
if (!UsersFriend::isFriend((int)$data['send_user'], (int)$data['receive_user'], true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if ($data['source_type'] == 2) {//群聊
|
} else if ($data['source_type'] == 2) {//群聊
|
||||||
|
|
|
@ -11,11 +11,11 @@ declare(strict_types=1);
|
||||||
*/
|
*/
|
||||||
return [
|
return [
|
||||||
'default' => [
|
'default' => [
|
||||||
'host' => '47.105.180.123',
|
'host' => env('AMQP_HOST','127.0.0.1'),
|
||||||
'port' => 5672,
|
'port' => intval(env('AMQP_PORT',5672)),
|
||||||
'user' => 'yuandong',
|
'user' => env('AMQP_USER','guest'),
|
||||||
'password' => 'yuandong',
|
'password' => env('AMQP_PASSWORD','guest'),
|
||||||
'vhost' => 'im',
|
'vhost' => env('AMQP_VHOST','/'),
|
||||||
'pool' => [
|
'pool' => [
|
||||||
'min_connections' => 1,
|
'min_connections' => 1,
|
||||||
'max_connections' => 10,
|
'max_connections' => 10,
|
||||||
|
|
Loading…
Reference in New Issue