mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-28 04:40:37 +00:00
no message
This commit is contained in:
parent
ef7400e9d2
commit
6412efd031
@ -279,72 +279,7 @@ class DialogController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/msg/lists 08. 获取消息列表
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup dialog
|
||||
* @apiName msg__lists
|
||||
*
|
||||
* @apiParam {Number} dialog_id 对话ID
|
||||
* @apiParam {Number} [position_id] 定位消息ID(填写时page无效)
|
||||
*
|
||||
* @apiParam {Number} [page] 当前页,默认:1
|
||||
* @apiParam {Number} [pagesize] 每页显示数量,默认:50,最大:100
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function msg__lists()
|
||||
{
|
||||
$user = User::auth();
|
||||
//
|
||||
$dialog_id = intval(Request::input('dialog_id'));
|
||||
$position_id = intval(Request::input('position_id'));
|
||||
//
|
||||
$dialog = WebSocketDialog::checkDialog($dialog_id);
|
||||
//
|
||||
$builder = WebSocketDialogMsg::select([
|
||||
'web_socket_dialog_msgs.*',
|
||||
'read.mention',
|
||||
'read.read_at',
|
||||
])->leftJoin('web_socket_dialog_msg_reads as read', function ($leftJoin) use ($user) {
|
||||
$leftJoin
|
||||
->on('read.userid', '=', DB::raw($user->userid))
|
||||
->on('read.msg_id', '=', 'web_socket_dialog_msgs.id');
|
||||
})->where('web_socket_dialog_msgs.dialog_id', $dialog_id)->orderByDesc('web_socket_dialog_msgs.id');
|
||||
//
|
||||
$perPage = Base::getPaginate(100, 50);
|
||||
if ($position_id > 0) {
|
||||
$position_count = $builder->clone()->where('web_socket_dialog_msgs.id', '>=', $position_id)->count();
|
||||
$list = $builder->paginate($perPage, [], 'page', ceil($position_count / $perPage));
|
||||
} else {
|
||||
$list = $builder->paginate($perPage);
|
||||
}
|
||||
//
|
||||
if ($dialog->type == 'group' && $dialog->group_type == 'task') {
|
||||
$user->task_dialog_id = $dialog->id;
|
||||
$user->save();
|
||||
}
|
||||
// 去掉标记未读
|
||||
$isMarkDialogUser = WebSocketDialogUser::whereDialogId($dialog->id)->whereUserid($user->userid)->whereMarkUnread(1)->first();
|
||||
if ($isMarkDialogUser) {
|
||||
$isMarkDialogUser->mark_unread = 0;
|
||||
$isMarkDialogUser->save();
|
||||
}
|
||||
//
|
||||
$data = $list->toArray();
|
||||
if ($list->currentPage() === 1) {
|
||||
$data['dialog'] = $dialog->formatData($user->userid);
|
||||
}
|
||||
return Base::retSuccess('success', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/msg/list 09. 获取消息列表(新)
|
||||
* @api {get} api/dialog/msg/list 08. 获取消息列表
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
@ -374,7 +309,6 @@ class DialogController extends AbstractController
|
||||
*/
|
||||
public function msg__list()
|
||||
{
|
||||
Base::checkClientVersion('0.18.12');
|
||||
$user = User::auth();
|
||||
//
|
||||
$dialog_id = intval(Request::input('dialog_id'));
|
||||
@ -474,6 +408,43 @@ class DialogController extends AbstractController
|
||||
return Base::retSuccess('success', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public function msg__lists()
|
||||
{
|
||||
Base::checkClientVersion('0.18.12');
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/msg/one 09. 获取单条消息
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup dialog
|
||||
* @apiName msg__one
|
||||
*
|
||||
* @apiParam {Number} msg_id 消息ID
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function msg__one()
|
||||
{
|
||||
User::auth();
|
||||
//
|
||||
$msg_id = intval(Request::input('msg_id'));
|
||||
//
|
||||
$msg = WebSocketDialogMsg::whereId($msg_id)->first();
|
||||
if (empty($msg)) {
|
||||
return Base::retError("消息不存在或已被删除");
|
||||
}
|
||||
WebSocketDialog::checkDialog($msg->dialog_id);
|
||||
//
|
||||
return Base::retSuccess('success', $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/msg/unread 10. 获取未读消息数量
|
||||
*
|
||||
|
||||
@ -343,6 +343,9 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
if ($userids && !in_array($userid, $userids)) {
|
||||
continue;
|
||||
}
|
||||
if (empty($userid)) {
|
||||
continue;
|
||||
}
|
||||
WebSocketDialogMsgTodo::createInstance([
|
||||
'dialog_id' => $this->dialog_id,
|
||||
'msg_id' => $this->id,
|
||||
|
||||
@ -341,6 +341,7 @@
|
||||
:source="todoViewMsg"
|
||||
@on-view-text="onViewText"
|
||||
@on-view-file="onViewFile"
|
||||
@on-down-file="onDownFile"
|
||||
@on-emoji="onEmoji"
|
||||
simpleView/>
|
||||
<Button class="original-button" icon="md-exit" type="text" @click="onPosTodo">{{ $L("回到原文") }}</Button>
|
||||
@ -452,6 +453,7 @@ export default {
|
||||
|
||||
todoViewLoad: false,
|
||||
todoViewShow: false,
|
||||
todoViewTmp: {},
|
||||
todoViewMid: 0,
|
||||
todoViewId: 0,
|
||||
|
||||
@ -662,7 +664,16 @@ export default {
|
||||
},
|
||||
|
||||
todoViewMsg() {
|
||||
return this.todoViewMid ? this.dialogMsgs.find(item => item.id == this.todoViewMid) : null
|
||||
if (this.todoViewMid) {
|
||||
const msg = this.dialogMsgs.find(item => item.id == this.todoViewMid)
|
||||
if (msg) {
|
||||
return msg
|
||||
}
|
||||
if (this.todoViewTmp.id === this.todoViewMid) {
|
||||
return this.todoViewTmp
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
},
|
||||
|
||||
@ -1023,11 +1034,24 @@ export default {
|
||||
this.todoViewId = item.id
|
||||
this.todoViewMid = item.msg_id
|
||||
this.todoViewShow = true
|
||||
//
|
||||
const index = this.allMsgs.findIndex(item => item.id === this.todoViewMid)
|
||||
if (index === -1) {
|
||||
this.$store.dispatch("call", {
|
||||
url: 'dialog/msg/one',
|
||||
data: {
|
||||
msg_id: this.todoViewMid
|
||||
},
|
||||
}).then(({data}) => {
|
||||
this.todoViewTmp = data
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onCloseTodo() {
|
||||
this.todoViewLoad = false
|
||||
this.todoViewShow = false
|
||||
this.todoViewTmp = {}
|
||||
this.todoViewMid = 0
|
||||
this.todoViewId = 0
|
||||
},
|
||||
@ -1715,7 +1739,12 @@ export default {
|
||||
url: 'dialog/msg/emoji',
|
||||
data,
|
||||
}).then(({data}) => {
|
||||
this.$store.dispatch("saveDialogMsg", data);
|
||||
const index = this.dialogMsgs.findIndex(item => item.id == data.id)
|
||||
if (index > -1) {
|
||||
this.$store.dispatch("saveDialogMsg", data);
|
||||
} else if (this.todoViewTmp.id === data.id) {
|
||||
this.todoViewTmp = Object.assign({}, this.todoViewTmp, data)
|
||||
}
|
||||
}).catch(({msg}) => {
|
||||
$A.messageError(msg);
|
||||
}).finally(_ => {
|
||||
@ -1752,7 +1781,7 @@ export default {
|
||||
return
|
||||
}
|
||||
if (type === 'submit') {
|
||||
if ($A.arrayLength(this.todoSettingData.userids) === 0) {
|
||||
if (this.todoSettingData.type === 'user' && $A.arrayLength(this.todoSettingData.userids) === 0) {
|
||||
$A.messageWarning("选择指定成员");
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user