推送消息接口(添加群名称字段)
parent
6dc3e26e1e
commit
4d9f71ac61
|
@ -13,6 +13,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Amqp\Consumer;
|
||||
|
||||
use App\Model\Group\Group;
|
||||
use Hyperf\Amqp\Annotation\Consumer;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||
|
@ -152,8 +153,9 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
public function onConsumeTalk(array $data, AMQPMessage $message): string
|
||||
{
|
||||
$source = $data['data']['source'];
|
||||
|
||||
$fds = $this->socketClientService->findUserFds($data['data']['sender']);
|
||||
$group_name = '';
|
||||
|
||||
if ($source == 1) {// 私聊
|
||||
$fds = array_merge($fds, $this->socketClientService->findUserFds($data['data']['receive']));
|
||||
} else if ($source == 2) {// 群聊
|
||||
|
@ -161,12 +163,12 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
foreach ($userIds as $uid) {
|
||||
$fds = array_merge($fds, $this->socketClientService->findUserFds((int)$uid));
|
||||
}
|
||||
|
||||
$group_name = Group::where('id', $data['data']['receive'])->value('group_name');
|
||||
}
|
||||
|
||||
// 客户端ID去重
|
||||
if (!$fds = array_unique($fds)) {
|
||||
return Result::ACK;
|
||||
}
|
||||
if (!$fds = array_unique($fds)) return Result::ACK;
|
||||
|
||||
/**
|
||||
* @var ChatRecord
|
||||
|
@ -182,17 +184,14 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
'chat_records.content',
|
||||
'chat_records.is_revoke',
|
||||
'chat_records.created_at',
|
||||
|
||||
'users.nickname',
|
||||
'users.avatar as avatar',
|
||||
'users.avatar',
|
||||
]);
|
||||
|
||||
if (!$result) return Result::ACK;
|
||||
|
||||
$file = [];
|
||||
$code_block = [];
|
||||
$forward = [];
|
||||
$invite = [];
|
||||
$file = $code_block = $forward = $invite = [];
|
||||
|
||||
switch ($result->msg_type) {
|
||||
case 2:// 文件消息
|
||||
$file = ChatRecordsFile::where('record_id', $result->id)->first(['id', 'record_id', 'user_id', 'file_source', 'file_type', 'save_type', 'original_name', 'file_suffix', 'file_size', 'save_dir']);
|
||||
|
@ -206,7 +205,6 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
]);
|
||||
|
||||
$userInfo = User::where('id', $notifyInfo->operate_user_id)->first(['nickname', 'id']);
|
||||
|
||||
$invite = [
|
||||
'type' => $notifyInfo->type,
|
||||
'operate_user' => ['id' => $userInfo->id, 'nickname' => $userInfo->nickname],
|
||||
|
@ -217,7 +215,6 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
break;
|
||||
case 4: //会话记录消息
|
||||
$forward = ['num' => 0, 'list' => []];
|
||||
|
||||
$forwardInfo = ChatRecordsForward::where('record_id', $result->id)->first(['records_id', 'text']);
|
||||
if ($forwardInfo) {
|
||||
$forward = [
|
||||
|
@ -243,6 +240,7 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
'source' => $result->source,
|
||||
'avatar' => $result->avatar,
|
||||
'nickname' => $result->nickname,
|
||||
'group_name' => $group_name,
|
||||
"user_id" => $result->user_id,
|
||||
"receive_id" => $result->receive_id,
|
||||
"created_at" => $result->created_at,
|
||||
|
@ -382,8 +380,9 @@ class ChatMessageConsumer extends ConsumerMessage
|
|||
"is_revoke" => 0,// 消息是否撤销
|
||||
|
||||
// 发送消息人的信息
|
||||
"nickname" => "",
|
||||
"avatar" => "",
|
||||
"nickname" => "",// 用户昵称
|
||||
"avatar" => "",// 用户头像
|
||||
"group_name" => "",// 群组名称
|
||||
|
||||
// 不同的消息类型
|
||||
"file" => [],
|
||||
|
|
Loading…
Reference in New Issue