mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-10 18:02:55 +00:00
feat: 新增不显示会话功能
This commit is contained in:
parent
0a51225762
commit
c555b309bd
@ -108,7 +108,7 @@ class DialogController extends AbstractController
|
||||
return Base::retError('请输入搜索关键词');
|
||||
}
|
||||
// 搜索会话
|
||||
$dialogs = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.color', 'u.updated_at as user_at'])
|
||||
$dialogs = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.hide', 'u.color', 'u.updated_at as user_at'])
|
||||
->join('web_socket_dialog_users as u', 'web_socket_dialogs.id', '=', 'u.dialog_id')
|
||||
->where('web_socket_dialogs.name', 'LIKE', "%{$key}%")
|
||||
->where('u.userid', $user->userid)
|
||||
@ -145,7 +145,7 @@ class DialogController extends AbstractController
|
||||
}
|
||||
// 搜索消息会话
|
||||
if (count($list) < 20) {
|
||||
$msgs = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.color', 'u.updated_at as user_at', 'm.id as search_msg_id'])
|
||||
$msgs = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.hide', 'u.color', 'u.updated_at as user_at', 'm.id as search_msg_id'])
|
||||
->join('web_socket_dialog_users as u', 'web_socket_dialogs.id', '=', 'u.dialog_id')
|
||||
->join('web_socket_dialog_msgs as m', 'web_socket_dialogs.id', '=', 'm.dialog_id')
|
||||
->where('u.userid', $user->userid)
|
||||
@ -178,7 +178,7 @@ class DialogController extends AbstractController
|
||||
{
|
||||
$user = User::auth();
|
||||
// 搜索会话
|
||||
$msgs = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.color', 'u.updated_at as user_at', 'm.id as search_msg_id'])
|
||||
$msgs = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.hide', 'u.color', 'u.updated_at as user_at', 'm.id as search_msg_id'])
|
||||
->join('web_socket_dialog_users as u', 'web_socket_dialogs.id', '=', 'u.dialog_id')
|
||||
->join('web_socket_dialog_msgs as m', 'web_socket_dialogs.id', '=', 'm.dialog_id')
|
||||
->where('u.userid', $user->userid)
|
||||
@ -213,7 +213,7 @@ class DialogController extends AbstractController
|
||||
//
|
||||
$dialog_id = intval(Request::input('dialog_id'));
|
||||
//
|
||||
$item = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.color', 'u.updated_at as user_at'])
|
||||
$item = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.hide', 'u.color', 'u.updated_at as user_at'])
|
||||
->join('web_socket_dialog_users as u', 'web_socket_dialogs.id', '=', 'u.dialog_id')
|
||||
->where('web_socket_dialogs.id', $dialog_id)
|
||||
->where('u.userid', $user->userid)
|
||||
@ -330,6 +330,41 @@ class DialogController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/hide 08. 会话隐藏
|
||||
*
|
||||
* @apiDescription 需要token身份
|
||||
* @apiVersion 1.0.0
|
||||
* @apiGroup dialog
|
||||
* @apiName hide
|
||||
*
|
||||
* @apiParam {Number} dialog_id 会话ID
|
||||
*
|
||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||
* @apiSuccess {Object} data 返回数据
|
||||
*/
|
||||
public function hide()
|
||||
{
|
||||
$user = User::auth();
|
||||
$dialogId = intval(Request::input('dialog_id'));
|
||||
$dialogUser = WebSocketDialogUser::whereUserid($user->userid)->whereDialogId($dialogId)->first();
|
||||
if (!$dialogUser) {
|
||||
return Base::retError("会话不存在");
|
||||
}
|
||||
if ($dialogUser->top_at) {
|
||||
return Base::retError("置顶会话无法隐藏");
|
||||
}
|
||||
$dialogUser->hide = 1;
|
||||
$dialogUser->save();
|
||||
return Base::retSuccess("success", [
|
||||
'id' => $dialogUser->dialog_id,
|
||||
'hide' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} api/dialog/tel 09. 获取对方联系电话
|
||||
*
|
||||
|
||||
@ -81,7 +81,7 @@ class WebSocketDialog extends AbstractModel
|
||||
*/
|
||||
public static function getDialogList($userid, $updated = "", $deleted = "")
|
||||
{
|
||||
$builder = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.color', 'u.updated_at as user_at'])
|
||||
$builder = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.hide', 'u.color', 'u.updated_at as user_at'])
|
||||
->join('web_socket_dialog_users as u', 'web_socket_dialogs.id', '=', 'u.dialog_id')
|
||||
->where('u.userid', $userid);
|
||||
if ($updated) {
|
||||
@ -112,7 +112,7 @@ class WebSocketDialog extends AbstractModel
|
||||
public static function getDialogUnread($userid, $beforeAt, $take = 20)
|
||||
{
|
||||
DB::statement("SET SQL_MODE=''");
|
||||
$list = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.color', 'u.updated_at as user_at'])
|
||||
$list = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.hide', 'u.color', 'u.updated_at as user_at'])
|
||||
->join('web_socket_dialog_users as u', 'web_socket_dialogs.id', '=', 'u.dialog_id')
|
||||
->join('web_socket_dialog_msg_reads as r', 'web_socket_dialogs.id', '=', 'r.dialog_id')
|
||||
->where('u.userid', $userid)
|
||||
@ -147,6 +147,7 @@ class WebSocketDialog extends AbstractModel
|
||||
};
|
||||
//
|
||||
$time = Carbon::parse($this->user_at ?? $dialogUserFun('updated_at'));
|
||||
$this->hide = $this->hide ?? $dialogUserFun('hide');
|
||||
$this->top_at = $this->top_at ?? $dialogUserFun('top_at');
|
||||
$this->user_at = $time->toDateTimeString('millisecond');
|
||||
$this->user_ms = $time->valueOf();
|
||||
|
||||
@ -888,6 +888,11 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
$dialogMsg->key = $dialogMsg->generateMsgKey();
|
||||
$dialogMsg->save();
|
||||
//
|
||||
WebSocketDialogUser::whereDialogId($dialog->id)->whereUserid($sender)->whereHide(1)->change([
|
||||
'hide' => 0, // 修改消息时,显示会话(仅自己)
|
||||
'updated_at' => Carbon::now()->toDateTimeString('millisecond'),
|
||||
]);
|
||||
//
|
||||
$dialogMsg->msgJoinGroup($dialog);
|
||||
//
|
||||
$dialog->pushMsg('update', array_merge($updateData, [
|
||||
@ -924,7 +929,11 @@ class WebSocketDialogMsg extends AbstractModel
|
||||
$dialogMsg->send = 1;
|
||||
$dialogMsg->key = $dialogMsg->generateMsgKey();
|
||||
$dialogMsg->save();
|
||||
WebSocketDialogUser::whereDialogId($dialog->id)->change(['updated_at' => Carbon::now()->toDateTimeString('millisecond')]);
|
||||
//
|
||||
WebSocketDialogUser::whereDialogId($dialog->id)->change([
|
||||
'hide' => 0, // 有新消息时,显示会话(会话内所有会员)
|
||||
'updated_at' => Carbon::now()->toDateTimeString('millisecond'),
|
||||
]);
|
||||
});
|
||||
//
|
||||
$task = new WebSocketDialogMsgTask($dialogMsg->id);
|
||||
|
||||
@ -316,7 +316,7 @@ class BotReceiveMsgTask extends AbstractTask
|
||||
$nameKey = $isManager ? $array[2] : $array[1];
|
||||
$data = $this->botManagerOne($botId, $msg->userid);
|
||||
if ($data) {
|
||||
$list = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.color', 'u.updated_at as user_at'])
|
||||
$list = WebSocketDialog::select(['web_socket_dialogs.*', 'u.top_at', 'u.mark_unread', 'u.silence', 'u.hide', 'u.color', 'u.updated_at as user_at'])
|
||||
->join('web_socket_dialog_users as u', 'web_socket_dialogs.id', '=', 'u.dialog_id')
|
||||
->where('web_socket_dialogs.name', 'LIKE', "%{$nameKey}%")
|
||||
->where('u.userid', $data->userid)
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddWebSocketDialogUsersAddHide extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('web_socket_dialog_users', function (Blueprint $table) {
|
||||
if (!Schema::hasColumn('web_socket_dialog_users', 'hide')) {
|
||||
$table->integer('hide')->nullable()->default(0)->after('silence')->comment('不显示会话:0否,1是');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('web_socket_dialog_users', function (Blueprint $table) {
|
||||
$table->dropColumn("hide");
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -2020,6 +2020,10 @@ export default {
|
||||
this.forgetTempMsg(data.id)
|
||||
}, 1000)
|
||||
}
|
||||
this.$store.dispatch("saveDialog", {
|
||||
id: this.dialogId,
|
||||
hide: 0,
|
||||
})
|
||||
this.$store.dispatch("saveDialogMsg", data);
|
||||
if (!isUpdate) {
|
||||
this.$store.dispatch("increaseTaskMsgNum", data);
|
||||
|
||||
@ -185,6 +185,12 @@
|
||||
<i class="taskfont" v-html="operateItem.silence ? '' : ''"></i>
|
||||
</div>
|
||||
</DropdownItem>
|
||||
<DropdownItem @click.native="handleHideClick" :disabled="operateItem.top_at">
|
||||
<div class="item">
|
||||
{{ $L('不显示该会话') }}
|
||||
<i class="taskfont"></i>
|
||||
</div>
|
||||
</DropdownItem>
|
||||
<DropdownItem @click.native="handleColorClick(c.color)" v-for="(c, k) in taskColorList" :key="'c_' + k" :divided="k==0" v-if="k<6" >
|
||||
<div class="item">
|
||||
{{$L(c.name)}}
|
||||
@ -353,11 +359,11 @@ export default {
|
||||
if (dialogActive == '' && dialogSearchKey == '') {
|
||||
return this.cacheDialogs.filter(dialog => this.filterDialog(dialog)).sort(this.dialogSort);
|
||||
}
|
||||
if(dialogActive == 'mark' && !dialogSearchKey){
|
||||
if (dialogActive == 'mark' && !dialogSearchKey) {
|
||||
const lists = [];
|
||||
this.dialogMsgs.filter(h=>h.tag).forEach(h=>{
|
||||
let dialog = $A.cloneJSON(this.cacheDialogs).find(p=>p.id == h.dialog_id)
|
||||
if(dialog){
|
||||
this.dialogMsgs.filter(h => h.tag).forEach(h => {
|
||||
let dialog = $A.cloneJSON(this.cacheDialogs).find(p => p.id == h.dialog_id)
|
||||
if (dialog) {
|
||||
dialog.last_msg = h;
|
||||
dialog.search_msg_id = h.id;
|
||||
lists.push(dialog);
|
||||
@ -375,7 +381,7 @@ export default {
|
||||
if (last_msg) {
|
||||
switch (last_msg.type) {
|
||||
case 'text':
|
||||
searchString += ` ${last_msg.msg.text.replace(/<[^>]+>/g,"")}`
|
||||
searchString += ` ${last_msg.msg.text.replace(/<[^>]+>/g, "")}`
|
||||
break
|
||||
case 'meeting':
|
||||
case 'file':
|
||||
@ -745,7 +751,7 @@ export default {
|
||||
if (dialog.name === undefined || dialog.dialog_delete === 1) {
|
||||
return false;
|
||||
}
|
||||
if (!dialog.last_at) {
|
||||
if (dialog.hide || !dialog.last_at) {
|
||||
return false;
|
||||
}
|
||||
if (dialog.type == 'group') {
|
||||
@ -1030,6 +1036,22 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
handleHideClick() {
|
||||
this.$store.dispatch("call", {
|
||||
url: 'dialog/hide',
|
||||
data: {
|
||||
dialog_id: this.operateItem.id,
|
||||
},
|
||||
}).then(({data}) => {
|
||||
if (this.dialogId == this.operateItem.id) {
|
||||
this.$store.dispatch("openDialog", 0)
|
||||
}
|
||||
this.$store.dispatch("saveDialog", data);
|
||||
}).catch(({msg}) => {
|
||||
$A.modalError(msg);
|
||||
});
|
||||
},
|
||||
|
||||
handleColorClick(color) {
|
||||
this.$store.dispatch("call", {
|
||||
url: 'dialog/msg/color',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user