feat:兼容开发
parent
3cea1388fb
commit
cdbf6fdc56
|
@ -3,7 +3,7 @@
|
|||
namespace App\Cache;
|
||||
|
||||
use App\Cache\Repository\HashRedis;
|
||||
use App\Model\Contact;
|
||||
use App\Model\Contact\Contact;
|
||||
|
||||
/**
|
||||
* 好友备注 - 缓存助手
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace App\Command;
|
|||
|
||||
use App\Cache\IpAddressCache;
|
||||
use App\Constants\RobotConstant;
|
||||
use App\Model\Contact;
|
||||
use App\Model\Contact\Contact;
|
||||
use App\Repository\ExampleRepository;
|
||||
use App\Repository\RobotRepository;
|
||||
use App\Service\RobotService;
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
namespace App\Controller\Api\V1\Talk;
|
||||
|
||||
use App\Cache\UnreadTalkCache;
|
||||
use App\Constants\TalkEventConstant;
|
||||
use App\Constants\TalkModeConstant;
|
||||
use App\Controller\Api\V1\CController;
|
||||
use App\Event\TalkEvent;
|
||||
use App\Model\EmoticonItem;
|
||||
use App\Model\FileSplitUpload;
|
||||
|
@ -29,7 +30,7 @@ use Psr\Http\Message\ResponseInterface;
|
|||
*
|
||||
* @package App\Controller\Api\V1
|
||||
*/
|
||||
class TalkMessageController extends CController
|
||||
class MessageController extends CController
|
||||
{
|
||||
/**
|
||||
* @Inject
|
||||
|
@ -75,6 +76,7 @@ class TalkMessageController extends CController
|
|||
public function code(): ResponseInterface
|
||||
{
|
||||
$params = $this->request->inputs(['talk_type', 'receiver_id', 'lang', 'code']);
|
||||
|
||||
$this->validate($params, [
|
||||
'talk_type' => 'required|in:1,2',
|
||||
'receiver_id' => 'required|integer|min:1',
|
||||
|
@ -83,6 +85,7 @@ class TalkMessageController extends CController
|
|||
]);
|
||||
|
||||
$user_id = $this->uid();
|
||||
|
||||
if (!UserRelation::isFriendOrGroupMember($user_id, (int)$params['receiver_id'], (int)$params['talk_type'])) {
|
||||
return $this->response->fail('暂不属于好友关系或群聊成员,无法发送聊天消息!');
|
||||
}
|
||||
|
@ -93,7 +96,7 @@ class TalkMessageController extends CController
|
|||
'receiver_id' => $params['receiver_id'],
|
||||
], [
|
||||
'user_id' => $user_id,
|
||||
'code_lang' => $params['lang'],
|
||||
'lang' => $params['lang'],
|
||||
'code' => $params['code']
|
||||
]);
|
||||
|
||||
|
@ -110,12 +113,14 @@ class TalkMessageController extends CController
|
|||
public function image(Filesystem $filesystem): ResponseInterface
|
||||
{
|
||||
$params = $this->request->inputs(['talk_type', 'receiver_id']);
|
||||
|
||||
$this->validate($params, [
|
||||
'talk_type' => 'required|in:1,2',
|
||||
'receiver_id' => 'required|integer|min:1'
|
||||
]);
|
||||
|
||||
$user_id = $this->uid();
|
||||
|
||||
if (!UserRelation::isFriendOrGroupMember($user_id, (int)$params['receiver_id'], (int)$params['talk_type'])) {
|
||||
return $this->response->fail('暂不属于好友关系或群聊成员,无法发送聊天消息!');
|
||||
}
|
||||
|
@ -163,6 +168,7 @@ class TalkMessageController extends CController
|
|||
public function file(Filesystem $filesystem): ResponseInterface
|
||||
{
|
||||
$params = $this->request->inputs(['talk_type', 'receiver_id', 'hash_name']);
|
||||
|
||||
$this->validate($params, [
|
||||
'talk_type' => 'required|in:1,2',
|
||||
'receiver_id' => 'required|integer|min:1',
|
||||
|
@ -314,11 +320,11 @@ class TalkMessageController extends CController
|
|||
};
|
||||
|
||||
if (isset($params['receive_user_ids']) && !empty($params['receive_user_ids'])) {
|
||||
$receive_user_ids = $func($params['receive_user_ids'], TalkModeConstant::PRIVATE_CHAT);
|
||||
$receive_user_ids = $func(parse_ids($params['receive_user_ids']), TalkModeConstant::PRIVATE_CHAT);
|
||||
}
|
||||
|
||||
if (isset($params['receive_group_ids']) && !empty($params['receive_group_ids'])) {
|
||||
$receive_group_ids = $func($params['receive_group_ids'], TalkModeConstant::GROUP_CHAT);
|
||||
$receive_group_ids = $func(parse_ids($params['receive_group_ids']), TalkModeConstant::GROUP_CHAT);
|
||||
}
|
||||
|
||||
// 需要转发的好友或者群组
|
||||
|
@ -326,7 +332,7 @@ class TalkMessageController extends CController
|
|||
|
||||
$method = $params['forward_mode'] == 1 ? "multiSplitForward" : "multiMergeForward";
|
||||
|
||||
$ids = $forwardService->{$method}($user_id, (int)$params['receiver_id'], (int)$params['talk_type'], $params['records_ids'], $items);
|
||||
$ids = $forwardService->{$method}($user_id, (int)$params['receiver_id'], (int)$params['talk_type'], parse_ids($params['records_ids']), $items);
|
||||
|
||||
if (!$ids) return $this->response->fail('转发失败!');
|
||||
|
||||
|
@ -434,6 +440,7 @@ class TalkMessageController extends CController
|
|||
public function handleVote(): ResponseInterface
|
||||
{
|
||||
$params = $this->request->inputs(['record_id', 'options']);
|
||||
|
||||
$this->validate($params, [
|
||||
'record_id' => 'required|integer|min:1',
|
||||
'options' => 'required',
|
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Api\V1\Talk;
|
||||
|
||||
use App\Constants\TalkMessageType;
|
||||
use App\Constants\TalkModeConstant;
|
||||
use App\Controller\Api\V1\CController;
|
||||
use App\Service\Group\GroupMemberService;
|
||||
use App\Service\TalkListService;
|
||||
use App\Service\TalkService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\HttpServer\Annotation\Controller;
|
||||
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||
use Hyperf\HttpServer\Annotation\Middleware;
|
||||
use App\Middleware\JWTAuthMiddleware;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Class RecordController
|
||||
*
|
||||
* @Controller(prefix="/api/v1/talk/records")
|
||||
* @Middleware(JWTAuthMiddleware::class)
|
||||
*
|
||||
* @package App\Controller\Api\V1\Talk
|
||||
*/
|
||||
class RecordsController extends CController
|
||||
{
|
||||
/**
|
||||
* @Inject
|
||||
* @var TalkService
|
||||
*/
|
||||
public $talkService;
|
||||
|
||||
/**
|
||||
* @Inject
|
||||
* @var TalkListService
|
||||
*/
|
||||
public $talkListService;
|
||||
|
||||
/**
|
||||
* 获取对话面板中的聊天记录
|
||||
*
|
||||
* @RequestMapping(path="", methods="get")
|
||||
*/
|
||||
public function records(): ResponseInterface
|
||||
{
|
||||
$params = $this->request->inputs(['talk_type', 'receiver_id', 'record_id']);
|
||||
|
||||
$this->validate($params, [
|
||||
'talk_type' => 'required|in:1,2',
|
||||
'receiver_id' => 'required|integer|min:1',
|
||||
'record_id' => 'required|integer|min:0',
|
||||
]);
|
||||
|
||||
$user_id = $this->uid();
|
||||
|
||||
if ($params['talk_type'] == TalkModeConstant::GROUP_CHAT && !di()->get(GroupMemberService::class)->isMember((int)$params['receiver_id'], $user_id)) {
|
||||
return $this->response->fail('暂不属于好友关系或群聊成员,无法查看聊天记录!');
|
||||
}
|
||||
|
||||
$limit = 30;
|
||||
$result = $this->talkService->getChatRecords(
|
||||
$user_id,
|
||||
intval($params['receiver_id']),
|
||||
intval($params['talk_type']),
|
||||
intval($params['record_id']),
|
||||
$limit
|
||||
);
|
||||
|
||||
return $this->response->success([
|
||||
'rows' => $result,
|
||||
'record_id' => $result ? end($result)['id'] : 0,
|
||||
'limit' => $limit
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询聊天历史记录
|
||||
*
|
||||
* @RequestMapping(path="history", methods="get")
|
||||
*/
|
||||
public function history(): ResponseInterface
|
||||
{
|
||||
$params = $this->request->inputs(['talk_type', 'receiver_id', 'record_id', 'msg_type']);
|
||||
|
||||
$this->validate($params, [
|
||||
'talk_type' => 'required|in:1,2',
|
||||
'receiver_id' => 'required|integer|min:1',
|
||||
'record_id' => 'required|integer|min:0',
|
||||
'msg_type' => 'required|integer',
|
||||
]);
|
||||
|
||||
$user_id = $this->uid();
|
||||
|
||||
if ($params['talk_type'] == TalkModeConstant::GROUP_CHAT && !di()->get(GroupMemberService::class)->isMember((int)$params['receiver_id'], $user_id)) {
|
||||
return $this->response->fail('暂不属于好友关系或群聊成员,无法查看聊天记录!');
|
||||
}
|
||||
|
||||
$types = [
|
||||
TalkMessageType::TEXT_MESSAGE,
|
||||
TalkMessageType::FILE_MESSAGE,
|
||||
TalkMessageType::FORWARD_MESSAGE,
|
||||
TalkMessageType::CODE_MESSAGE,
|
||||
TalkMessageType::VOTE_MESSAGE
|
||||
];
|
||||
|
||||
if (in_array($params['msg_type'], $types)) {
|
||||
$msg_type = [$params['msg_type']];
|
||||
} else {
|
||||
$msg_type = $types;
|
||||
}
|
||||
|
||||
$limit = 30;
|
||||
$result = $this->talkService->getChatRecords(
|
||||
$user_id,
|
||||
(int)$params['receiver_id'],
|
||||
(int)$params['talk_type'],
|
||||
(int)$params['record_id'],
|
||||
$limit,
|
||||
$msg_type
|
||||
);
|
||||
|
||||
return $this->response->success([
|
||||
'rows' => $result,
|
||||
'record_id' => $result ? end($result)['id'] : 0,
|
||||
'limit' => $limit
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取转发记录详情
|
||||
*
|
||||
* @RequestMapping(path="forward", methods="get")
|
||||
*/
|
||||
public function forwards(): ResponseInterface
|
||||
{
|
||||
$params = $this->request->inputs(['record_id']);
|
||||
|
||||
$this->validate($params, [
|
||||
'record_id' => 'required|integer|min:1'
|
||||
]);
|
||||
|
||||
$rows = $this->talkService->getForwardRecords($this->uid(), intval($params['record_id']));
|
||||
|
||||
return $this->response->success(['rows' => $rows]);
|
||||
}
|
||||
}
|
|
@ -1,14 +1,18 @@
|
|||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Api\V1;
|
||||
namespace App\Controller\Api\V1\Talk;
|
||||
|
||||
use App\Cache\LastMessage;
|
||||
use App\Cache\Repository\LockRedis;
|
||||
use App\Cache\UnreadTalkCache;
|
||||
use App\Constants\TalkMessageType;
|
||||
use App\Constants\TalkModeConstant;
|
||||
use App\Controller\Api\V1\CController;
|
||||
use App\Model\Group\Group;
|
||||
use App\Model\Talk\TalkSession;
|
||||
use App\Service\Group\GroupMemberService;
|
||||
use App\Model\User;
|
||||
use App\Service\TalkListService;
|
||||
use App\Service\TalkService;
|
||||
use App\Service\UserFriendService;
|
||||
use App\Support\UserRelation;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
@ -17,10 +21,6 @@ use Hyperf\HttpServer\Annotation\RequestMapping;
|
|||
use Hyperf\HttpServer\Annotation\Middleware;
|
||||
use App\Middleware\JWTAuthMiddleware;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use App\Model\User;
|
||||
use App\Model\Group\Group;
|
||||
use App\Service\TalkService;
|
||||
use App\Service\TalkListService;
|
||||
|
||||
/**
|
||||
* Class TalkController
|
||||
|
@ -65,6 +65,7 @@ class TalkController extends CController
|
|||
|
||||
/**
|
||||
* 新增对话列表
|
||||
*
|
||||
* @RequestMapping(path="create", methods="post")
|
||||
*/
|
||||
public function create(UserFriendService $service): ResponseInterface
|
||||
|
@ -124,6 +125,7 @@ class TalkController extends CController
|
|||
|
||||
/**
|
||||
* 删除对话列表
|
||||
*
|
||||
* @RequestMapping(path="delete", methods="post")
|
||||
*/
|
||||
public function delete(): ResponseInterface
|
||||
|
@ -140,6 +142,7 @@ class TalkController extends CController
|
|||
|
||||
/**
|
||||
* 对话列表置顶
|
||||
*
|
||||
* @RequestMapping(path="topping", methods="post")
|
||||
*/
|
||||
public function topping(): ResponseInterface
|
||||
|
@ -157,6 +160,7 @@ class TalkController extends CController
|
|||
|
||||
/**
|
||||
* 设置消息免打扰状态
|
||||
*
|
||||
* @RequestMapping(path="disturb", methods="post")
|
||||
*/
|
||||
public function disturb(): ResponseInterface
|
||||
|
@ -175,7 +179,7 @@ class TalkController extends CController
|
|||
|
||||
/**
|
||||
* 更新对话列表未读数
|
||||
* @RequestMapping(path="update-unread-num", methods="post")
|
||||
* @RequestMapping(path="unread/clear", methods="post")
|
||||
*/
|
||||
public function updateUnreadNum(): ResponseInterface
|
||||
{
|
||||
|
@ -192,105 +196,4 @@ class TalkController extends CController
|
|||
|
||||
return $this->response->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对话面板中的聊天记录
|
||||
* @RequestMapping(path="records", methods="get")
|
||||
*/
|
||||
public function getChatRecords(): ResponseInterface
|
||||
{
|
||||
$params = $this->request->inputs(['talk_type', 'receiver_id', 'record_id']);
|
||||
$this->validate($params, [
|
||||
'talk_type' => 'required|in:1,2',
|
||||
'receiver_id' => 'required|integer|min:1',
|
||||
'record_id' => 'required|integer|min:0',
|
||||
]);
|
||||
|
||||
$user_id = $this->uid();
|
||||
|
||||
if ($params['talk_type'] == TalkModeConstant::GROUP_CHAT && !di()->get(GroupMemberService::class)->isMember((int)$params['receiver_id'], $user_id)) {
|
||||
return $this->response->fail('暂不属于好友关系或群聊成员,无法查看聊天记录!');
|
||||
}
|
||||
|
||||
$limit = 30;
|
||||
$result = $this->talkService->getChatRecords(
|
||||
$user_id,
|
||||
$params['receiver_id'],
|
||||
$params['talk_type'],
|
||||
$params['record_id'],
|
||||
$limit
|
||||
);
|
||||
|
||||
return $this->response->success([
|
||||
'rows' => $result,
|
||||
'record_id' => $result ? end($result)['id'] : 0,
|
||||
'limit' => $limit
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取转发记录详情
|
||||
* @RequestMapping(path="get-forward-records", methods="get")
|
||||
*/
|
||||
public function getForwardRecords(): ResponseInterface
|
||||
{
|
||||
$params = $this->request->inputs(['record_id']);
|
||||
$this->validate($params, [
|
||||
'record_id' => 'required|integer|min:1'
|
||||
]);
|
||||
|
||||
$rows = $this->talkService->getForwardRecords($this->uid(), $params['record_id']);
|
||||
|
||||
return $this->response->success(['rows' => $rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询聊天记录
|
||||
* @RequestMapping(path="find-chat-records", methods="get")
|
||||
*/
|
||||
public function findChatRecords(): ResponseInterface
|
||||
{
|
||||
$params = $this->request->inputs(['talk_type', 'receiver_id', 'record_id', 'msg_type']);
|
||||
$this->validate($params, [
|
||||
'talk_type' => 'required|in:1,2',
|
||||
'receiver_id' => 'required|integer|min:1',
|
||||
'record_id' => 'required|integer|min:0',
|
||||
'msg_type' => 'required|integer',
|
||||
]);
|
||||
|
||||
$user_id = $this->uid();
|
||||
if ($params['talk_type'] == TalkModeConstant::GROUP_CHAT && !di()->get(GroupMemberService::class)->isMember((int)$params['receiver_id'], $user_id)) {
|
||||
return $this->response->fail('暂不属于好友关系或群聊成员,无法查看聊天记录!');
|
||||
}
|
||||
|
||||
$types = [
|
||||
TalkMessageType::TEXT_MESSAGE,
|
||||
TalkMessageType::FILE_MESSAGE,
|
||||
TalkMessageType::FORWARD_MESSAGE,
|
||||
TalkMessageType::CODE_MESSAGE,
|
||||
TalkMessageType::VOTE_MESSAGE
|
||||
];
|
||||
|
||||
if (in_array($params['msg_type'], $types)) {
|
||||
$msg_type = [$params['msg_type']];
|
||||
} else {
|
||||
$msg_type = $types;
|
||||
}
|
||||
|
||||
$limit = 30;
|
||||
$result = $this->talkService->getChatRecords(
|
||||
$user_id,
|
||||
$params['receiver_id'],
|
||||
$params['talk_type'],
|
||||
$params['record_id'],
|
||||
$limit,
|
||||
$msg_type
|
||||
);
|
||||
|
||||
return $this->response->success([
|
||||
'rows' => $result,
|
||||
'record_id' => $result ? end($result)['id'] : 0,
|
||||
'limit' => $limit
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -30,6 +30,7 @@ class Article extends BaseModel
|
|||
protected $fillable = [
|
||||
'user_id',
|
||||
'class_id',
|
||||
'tags_id',
|
||||
'title',
|
||||
'abstract',
|
||||
'image',
|
||||
|
@ -37,6 +38,7 @@ class Article extends BaseModel
|
|||
'status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
|
|
|
@ -9,17 +9,19 @@ use App\Model\BaseModel;
|
|||
/**
|
||||
* 笔记附件数据表模型
|
||||
*
|
||||
* @property integer $id 笔记附件ID
|
||||
* @property integer $user_id 用户ID
|
||||
* @property integer $article_id 笔记ID
|
||||
* @property integer $drive 文件驱动
|
||||
* @property string $file_suffix 文件后缀名
|
||||
* @property int $file_size 文件大小
|
||||
* @property string $path 文件相对路径
|
||||
* @property int $id 自增ID
|
||||
* @property int $user_id 用户ID
|
||||
* @property int $article_id 笔记ID
|
||||
* @property int $drive 文件驱动
|
||||
* @property string $suffix 文件后缀名
|
||||
* @property int $size 文件大小
|
||||
* @property string $path 文件地址
|
||||
* @property string $original_name 文件原名
|
||||
* @property integer $status 文件状态
|
||||
* @property string $created_at 上传时间
|
||||
* @property int $status 文件状态
|
||||
* @property string $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
* @property string $deleted_at 删除时间
|
||||
*
|
||||
* @package App\Model\Article
|
||||
*/
|
||||
class ArticleAnnex extends BaseModel
|
||||
|
|
|
@ -15,12 +15,12 @@ use App\Model\BaseModel;
|
|||
* @property integer $sort 排序[值越小越靠前]
|
||||
* @property integer $is_default 默认分类[1:是;0:不是]
|
||||
* @property string $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
*
|
||||
* @package App\Model\Article
|
||||
*/
|
||||
class ArticleClass extends BaseModel
|
||||
{
|
||||
|
||||
|
||||
protected $table = 'article_class';
|
||||
|
||||
public $timestamps = true;
|
||||
|
|
|
@ -13,6 +13,7 @@ use App\Model\BaseModel;
|
|||
* @property integer $article_id 笔记ID
|
||||
* @property string $md_content 笔记MD格式内容
|
||||
* @property string $content 笔记html格式内容
|
||||
*
|
||||
* @package App\Model\Article
|
||||
*/
|
||||
class ArticleDetail extends BaseModel
|
||||
|
|
|
@ -14,6 +14,7 @@ use App\Model\BaseModel;
|
|||
* @property string $tag_name 标签名称
|
||||
* @property integer $sort 标签排序
|
||||
* @property integer $created_at 创建时间
|
||||
* @property integer $updated_at 更新时间
|
||||
*/
|
||||
class ArticleTag extends BaseModel
|
||||
{
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
namespace App\Model\Contact;
|
||||
|
||||
use App\Cache\FriendRemark;
|
||||
use App\Model\BaseModel;
|
||||
|
||||
/**
|
||||
* 表情包收藏数据表模型
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
namespace App\Model\Contact;
|
||||
|
||||
use App\Model\BaseModel;
|
||||
|
||||
/**
|
||||
* 好友添加申请数据表模型
|
||||
|
@ -23,7 +25,6 @@ class ContactApply extends BaseModel
|
|||
'friend_id',
|
||||
'remark',
|
||||
'created_at',
|
||||
'updated_at'
|
||||
];
|
||||
|
||||
protected $casts = [
|
|
@ -19,6 +19,7 @@ use App\Model\BaseModel;
|
|||
* @property integer $is_dismiss 是否已解散[0:否;1:是;]
|
||||
* @property string $created_at 创建时间
|
||||
* @property string $dismissed_at 解散时间
|
||||
*
|
||||
* @package App\Model\Group
|
||||
*/
|
||||
class Group extends BaseModel
|
||||
|
|
|
@ -12,7 +12,7 @@ use App\Model\BaseModel;
|
|||
* @property int $id 代码块ID
|
||||
* @property int $record_id 聊天记录ID
|
||||
* @property int $user_id 用户ID
|
||||
* @property string $code_lang 代码语言
|
||||
* @property string $lang 代码语言
|
||||
* @property string $code 代码详情
|
||||
* @property string $created_at 创建时间
|
||||
* @package App\Model\Chat
|
||||
|
@ -24,7 +24,7 @@ class TalkRecordsCode extends BaseModel
|
|||
protected $fillable = [
|
||||
'record_id',
|
||||
'user_id',
|
||||
'code_lang',
|
||||
'lang',
|
||||
'code',
|
||||
'created_at'
|
||||
];
|
||||
|
|
|
@ -12,14 +12,13 @@ use App\Model\BaseModel;
|
|||
* @property int $id 文件消息ID
|
||||
* @property int $record_id 聊天记录ID
|
||||
* @property int $user_id 用户ID
|
||||
* @property int $file_source 文件上传来源
|
||||
* @property int $file_type 文件类型
|
||||
* @property int $save_type 文件保存类型
|
||||
* @property int $source 文件上传来源
|
||||
* @property int $type 文件类型
|
||||
* @property int $drive 文件保存类型
|
||||
* @property string $original_name 文件原始名称
|
||||
* @property string $file_suffix 文件后缀名
|
||||
* @property int $file_size 文件大小
|
||||
* @property string $save_dir 文件保存路径
|
||||
* @property int $is_delete 是否已删除
|
||||
* @property string $suffix 文件后缀名
|
||||
* @property int $size 文件大小
|
||||
* @property string $path 文件保存路径
|
||||
* @property string $created_at 上传时间
|
||||
* @package App\Model\Chat
|
||||
*/
|
||||
|
@ -30,25 +29,23 @@ class TalkRecordsFile extends BaseModel
|
|||
protected $fillable = [
|
||||
'record_id',
|
||||
'user_id',
|
||||
'file_source',
|
||||
'file_type',
|
||||
'save_type',
|
||||
'source',
|
||||
'type',
|
||||
'drive',
|
||||
'original_name',
|
||||
'file_suffix',
|
||||
'file_size',
|
||||
'save_dir',
|
||||
'is_delete',
|
||||
'suffix',
|
||||
'size',
|
||||
'path',
|
||||
'created_at'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'record_id' => 'integer',
|
||||
'user_id' => 'integer',
|
||||
'file_source' => 'integer',
|
||||
'file_type' => 'integer',
|
||||
'save_type' => 'integer',
|
||||
'file_size' => 'integer',
|
||||
'is_delete' => 'integer',
|
||||
'source' => 'integer',
|
||||
'type' => 'integer',
|
||||
'drive' => 'integer',
|
||||
'size' => 'integer',
|
||||
'created_at' => 'datetime'
|
||||
];
|
||||
}
|
||||
|
|
|
@ -50,6 +50,8 @@ class RedisWebsocketSubscribe extends AbstractProcess
|
|||
//echo PHP_EOL . "chan : $chan , msg : $message";
|
||||
$data = json_decode($message, true);
|
||||
|
||||
var_dump("subscribe ====> {$message}");
|
||||
|
||||
$this->handleService->handle($data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ use App\Cache\FriendApply;
|
|||
use App\Constants\TalkEventConstant;
|
||||
use App\Event\TalkEvent;
|
||||
use App\Model\User;
|
||||
use App\Model\Contact;
|
||||
use App\Model\ContactApply;
|
||||
use App\Model\Contact\Contact;
|
||||
use App\Model\Contact\ContactApply;
|
||||
use App\Traits\PagingTrait;
|
||||
use Hyperf\DbConnection\Db;
|
||||
|
||||
|
|
|
@ -96,8 +96,8 @@ class FormatMessageService
|
|||
// 查询聊天文件信息
|
||||
if ($files) {
|
||||
$files = TalkRecordsFile::whereIn('record_id', $files)->get([
|
||||
'id', 'record_id', 'user_id', 'file_source', 'file_type', 'save_type',
|
||||
'original_name', 'file_suffix', 'file_size', 'save_dir'
|
||||
'id', 'record_id', 'user_id', 'source', 'type', 'drive',
|
||||
'original_name', 'suffix', 'size', 'path'
|
||||
])->keyBy('record_id')->toArray();
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ class FormatMessageService
|
|||
// 查询代码块消息
|
||||
if ($codes) {
|
||||
$codes = TalkRecordsCode::whereIn('record_id', $codes)->get([
|
||||
'record_id', 'code_lang', 'code'
|
||||
'record_id', 'lang', 'code'
|
||||
])->keyBy('record_id')->toArray();
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ class FormatMessageService
|
|||
case TalkMessageType::FILE_MESSAGE:
|
||||
$rows[$k]['file'] = $files[$row['id']] ?? [];
|
||||
if ($rows[$k]['file']) {
|
||||
$rows[$k]['file']['file_url'] = get_media_url($rows[$k]['file']['save_dir']);
|
||||
$rows[$k]['file']['file_url'] = get_media_url($rows[$k]['file']['path']);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -120,7 +120,8 @@ class SubscribeHandleService
|
|||
if (!$result) return;
|
||||
|
||||
$message = di()->get(FormatMessageService::class)->handleChatRecords([$result->toArray()])[0];
|
||||
$push = [
|
||||
|
||||
$this->push($fds, $this->toJson(TalkEventConstant::EVENT_TALK, [
|
||||
'sender_id' => $sender_id,
|
||||
'receiver_id' => $receiver_id,
|
||||
'talk_type' => $talk_type,
|
||||
|
@ -128,9 +129,7 @@ class SubscribeHandleService
|
|||
'group_name' => $groupInfo ? $groupInfo['group_name'] : '',
|
||||
'group_avatar' => $groupInfo ? $groupInfo['avatar'] : ''
|
||||
])
|
||||
];
|
||||
|
||||
$this->push($fds, json_encode([TalkEventConstant::EVENT_TALK, $push]));
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,7 +141,7 @@ class SubscribeHandleService
|
|||
{
|
||||
$fds = $this->clientService->findUserFds($data['data']['receiver_id']);
|
||||
|
||||
$this->push($fds, json_encode([TalkEventConstant::EVENT_KEYBOARD, $data['data']]));
|
||||
$this->push($fds, $this->toJson(TalkEventConstant::EVENT_KEYBOARD, $data['data']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,11 +165,9 @@ class SubscribeHandleService
|
|||
|
||||
$fds = array_unique(array_merge(...$fds));
|
||||
|
||||
$this->push($fds, json_encode([
|
||||
TalkEventConstant::EVENT_ONLINE_STATUS, [
|
||||
$this->push($fds, $this->toJson(TalkEventConstant::EVENT_ONLINE_STATUS, [
|
||||
'user_id' => $user_id,
|
||||
'status' => $status
|
||||
]
|
||||
]));
|
||||
}
|
||||
|
||||
|
@ -199,12 +196,12 @@ class SubscribeHandleService
|
|||
|
||||
if (!$fds) return;
|
||||
|
||||
$this->push($fds, json_encode([TalkEventConstant::EVENT_REVOKE_TALK, [
|
||||
$this->push($fds, $this->toJson(TalkEventConstant::EVENT_REVOKE_TALK, [
|
||||
'talk_type' => $record->talk_type,
|
||||
'sender_id' => $record->user_id,
|
||||
'receiver_id' => $record->receiver_id,
|
||||
'record_id' => $record->id,
|
||||
]]));
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -245,7 +242,12 @@ class SubscribeHandleService
|
|||
'mobile' => $friendInfo->mobile,
|
||||
];
|
||||
|
||||
$this->push(array_unique($fds), json_encode([TalkEventConstant::EVENT_FRIEND_APPLY, $msg]));
|
||||
$this->push(array_unique($fds), $this->toJson(TalkEventConstant::EVENT_FRIEND_APPLY, $msg));
|
||||
}
|
||||
|
||||
private function toJson(string $event, array $data): string
|
||||
{
|
||||
return json_encode(["event" => $event, "content" => $data]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -206,7 +206,7 @@ class TalkForwardService extends BaseService
|
|||
$code[] = [
|
||||
'record_id' => $res->id,
|
||||
'user_id' => $user_id,
|
||||
'code_lang' => $codeInfo['code_lang'],
|
||||
'code_lang' => $codeInfo['lang'],
|
||||
'code' => $codeInfo['code'],
|
||||
'created_at' => date('Y-m-d H:i:s')
|
||||
];
|
||||
|
|
|
@ -39,9 +39,10 @@ class Response
|
|||
$resp = [
|
||||
"code" => ResponseCode::SUCCESS,
|
||||
"message" => $message,
|
||||
"data" => $data,
|
||||
];
|
||||
|
||||
if ($data) $resp["data"] = $data;
|
||||
// if ($data) $resp["data"] = $data;
|
||||
|
||||
return $this->response->json($resp);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue