no message

This commit is contained in:
kuaifan 2022-07-01 16:11:37 +08:00
parent 830552c121
commit 42bc25381c
12 changed files with 80 additions and 33 deletions

View File

@ -284,7 +284,7 @@ class DialogController extends AbstractController
* @apiParam {Number} [prev_id] 此消息ID之前的数据
* @apiParam {Number} [next_id] 此消息ID之后的数据
* - position_id、prev_id、next_id 只有一个有效优先循序为position_id > prev_id > next_id
* @apiParam {String} [mtype] 消息类型
* @apiParam {String} [msg_type] 消息类型
* - tag: 标记
* - link: 链接
* - text: 文本
@ -309,7 +309,7 @@ class DialogController extends AbstractController
$position_id = intval(Request::input('position_id'));
$prev_id = intval(Request::input('prev_id'));
$next_id = intval(Request::input('next_id'));
$mtype = trim(Request::input('mtype'));
$msg_type = trim(Request::input('msg_type'));
$take = Base::getPaginate(100, 50, 'take');
$data = [];
//
@ -326,12 +326,17 @@ class DialogController extends AbstractController
->on('read.msg_id', '=', 'web_socket_dialog_msgs.id');
})->where('web_socket_dialog_msgs.dialog_id', $dialog_id);
//
if ($mtype === 'tag') {
$builder->where('tag', '>', 0);
} elseif ($mtype === 'link') {
$builder->whereLink(1);
} elseif (in_array($mtype, ['text', 'image', 'file', 'record', 'meeting'])) {
$builder->whereMtype($mtype);
if ($msg_type) {
if ($msg_type === 'tag') {
$builder->where('tag', '>', 0);
} elseif ($msg_type === 'link') {
$builder->whereLink(1);
} elseif (in_array($msg_type, ['text', 'image', 'file', 'record', 'meeting'])) {
$builder->whereMtype($msg_type);
} else {
return Base::retError('参数错误');
}
$reDialog = false;
}
if ($msg_id > 0) {
$builder->whereReplyId($msg_id);

View File

@ -1182,10 +1182,16 @@ class ProjectTask extends AbstractModel
public function completeTask($complete_at)
{
AbstractModel::transaction(function () use ($complete_at) {
$addMsg = empty($this->parent_id) && $this->dialog_id > 0;
if ($complete_at === null) {
// 标记未完成
$this->complete_at = null;
$this->addLog("标记{任务}未完成");
if ($addMsg) {
WebSocketDialogMsg::sendMsg($this->dialog_id, 0, 'notice', [
'notice' => '标记任务未完成'
]);
}
} else {
// 标记已完成
if ($this->parent_id == 0) {
@ -1198,6 +1204,11 @@ class ProjectTask extends AbstractModel
}
$this->complete_at = $complete_at;
$this->addLog("标记{任务}已完成");
if ($addMsg) {
WebSocketDialogMsg::sendMsg($this->dialog_id, 0, 'notice', [
'notice' => '标记任务已完成'
]);
}
}
$this->save();
});

View File

@ -146,6 +146,9 @@ class WebSocketDialog extends AbstractModel
], [
'inviter' => $inviter,
]);
WebSocketDialogMsg::sendMsg($this->id, 0, 'notice', [
'notice' => User::userid2nickname($value) . " 已加入群组"
], $inviter, true);
}
}
});
@ -158,7 +161,7 @@ class WebSocketDialog extends AbstractModel
/**
* 退出聊天室
* @param int|array $userid 加入的会员ID或会员ID组
* @param int|array $userid 退出的会员ID或会员ID组
* @param $type
*/
public function exitGroup($userid, $type = 'exit')
@ -184,6 +187,13 @@ class WebSocketDialog extends AbstractModel
throw new ApiException('项目人员或任务人员不可' . $typeDesc);
}
$item->delete();
//
if ($type === 'remove') {
$notice = User::nickname() . "" . User::userid2nickname($item->userid) . " 移出群组";
} else {
$notice = User::userid2nickname($item->userid) . " 退出群组";
}
WebSocketDialogMsg::sendMsg($this->id, 0, 'notice', ['notice' => $notice], User::userid(), true);
}
});
});

View File

@ -393,6 +393,8 @@ class WebSocketDialogMsg extends AbstractModel
case 'tag':
$action = $data['msg']['action'] === 'remove' ? '取消标注' : '标注';
return "[{$action}] {$this->previewMsg(false, $data['msg']['data'])}";
case 'notice':
return $data['msg']['notice'];
default:
return "[未知的消息]";
}
@ -519,9 +521,10 @@ class WebSocketDialogMsg extends AbstractModel
* @param string $type 消息类型
* @param array $msg 发送的消息
* @param int $sender 发送的会员ID默认自己0为系统
* @param bool $push_self 是否推送给自己
* @return array
*/
public static function sendMsg($dialog_id, $reply_id, $type, $msg, $sender = 0)
public static function sendMsg($dialog_id, $reply_id, $type, $msg, $sender = 0, $push_self = false)
{
$link = 0;
$mtype = $type;
@ -563,7 +566,13 @@ class WebSocketDialogMsg extends AbstractModel
$dialogMsg->key = $dialogMsg->generateMsgKey();
$dialogMsg->save();
});
Task::deliver(new WebSocketDialogMsgTask($dialogMsg->id));
//
$task = new WebSocketDialogMsgTask($dialogMsg->id);
if ($push_self) {
$task->setIgnoreFd(null);
}
Task::deliver($task);
//
return Base::retSuccess('发送成功', $dialogMsg);
}
}

View File

@ -32,6 +32,14 @@ class WebSocketDialogMsgTask extends AbstractTask
$this->ignoreFd = Request::header('fd');
}
/**
* @param $ignoreFd
*/
public function setIgnoreFd($ignoreFd)
{
$this->ignoreFd = $ignoreFd;
}
public function start()
{
global $_A;

View File

@ -5,9 +5,8 @@
<style type="text/css">
.st0{fill:#FFFFFF;}
</style>
<path class="st0" d="M905,334.3c-66-66-198.5-198.5-198.5-198.5c-53.8-53.8-112.3-61.2-152-29.4c-21.3,17-33.3,40.7-36.1,65.2
c-2.8,24.4-17.4,45.8-36.9,60.7l-6.5,5c-90.5,69.2-193.4,126.4-306.2,142.9c-25.2,3.7-49.2,17.1-65.7,40.3
c-28.3,39.7-19.4,95.2,15,129.7l153.3,153.3L133.2,841.8c-13.3,13.3-13.3,34.7,0,48c6.6,6.6,15.3,9.9,24,9.9c8.7,0,17.4-3.3,24-9.9
l138.3-138.3l129.1,129.1c58.8,58.8,113.7,67.5,153.3,39.7c20.1-14.1,33-33.8,38.6-55c27.5-104.2,62.3-206.4,127.2-292.4l23.3-31
c14.8-19.6,36.1-34.5,60.4-37.2c24.6-2.8,48.3-14.8,65.3-36.2C948.4,428.7,940.9,370.2,905,334.3z"/>
<path class="st0" d="M913.8,405.3L618.7,110.2c-31.1-31.1-81.9-31.1-113.1,0L110.2,505.6l0,0c-15.9,15.9-24.4,37.9-23.3,60.3
l13.4,281.7c2,41.4,34.7,74,76.1,76l281.7,13.4c1.2,0,2.5,0.1,3.7,0.1c21.1,0,41.6-8.4,56.6-23.4l395.4-395.4
C945,487.2,945,436.5,913.8,405.3z M390,736.1c-56.3,0-102.1-45.8-102.1-102.1S333.7,531.9,390,531.9c56.3,0,102,45.8,102,102.1
S446.3,736.1,390,736.1z"/>
</svg>

Before

Width:  |  Height:  |  Size: 995 B

After

Width:  |  Height:  |  Size: 797 B

View File

@ -5,9 +5,8 @@
<style type="text/css">
.st0{fill:#9D95E5;}
</style>
<path class="st0" d="M905,334.3c-66-66-198.5-198.5-198.5-198.5c-53.8-53.8-112.3-61.2-152-29.4c-21.3,17-33.3,40.7-36.1,65.2
c-2.8,24.4-17.4,45.8-36.9,60.7l-6.5,5c-90.5,69.2-193.4,126.4-306.2,142.9c-25.2,3.7-49.2,17.1-65.7,40.3
c-28.3,39.7-19.4,95.2,15,129.7l153.3,153.3L133.2,841.8c-13.3,13.3-13.3,34.7,0,48c6.6,6.6,15.3,9.9,24,9.9c8.7,0,17.4-3.3,24-9.9
l138.3-138.3l129.1,129.1c58.8,58.8,113.7,67.5,153.3,39.7c20.1-14.1,33-33.8,38.6-55c27.5-104.2,62.3-206.4,127.2-292.4l23.3-31
c14.8-19.6,36.1-34.5,60.4-37.2c24.6-2.8,48.3-14.8,65.3-36.2C948.4,428.7,940.9,370.2,905,334.3z"/>
<path class="st0" d="M909.9,408.7L614.8,113.6c-31.1-31.1-81.9-31.1-113.1,0L106.3,509l0,0c-15.9,15.9-24.4,37.9-23.3,60.3
l13.4,281.7c2,41.4,34.7,74,76.1,76l281.7,13.4c1.2,0,2.5,0.1,3.7,0.1c21.1,0,41.6-8.4,56.6-23.4l395.4-395.4
C941.1,490.6,941.1,439.9,909.9,408.7z M386.1,739.4c-56.3,0-102.1-45.8-102.1-102.1s45.8-102.1,102.1-102.1
c56.3,0,102,45.8,102,102.1S442.3,739.4,386.1,739.4z"/>
</svg>

Before

Width:  |  Height:  |  Size: 995 B

After

Width:  |  Height:  |  Size: 804 B

View File

@ -489,6 +489,8 @@
return `[${$A.L('文件')}] ${data.msg.name}`
case 'tag':
return `[${$A.L(data.msg.action === 'remove' ? '取消标注' : '标注')}] ${$A.getMsgSimpleDesc(data.msg.data)}`
case 'notice':
return data.msg.notice
default:
return `[${$A.L('未知的消息')}]`
}

View File

@ -5,6 +5,9 @@
{{$L(source.msg.action === 'remove' ? '取消标注' : '标注了')}}
"{{$A.getMsgSimpleDesc(source.msg.data)}}"
</div>
<div v-else-if="source.type === 'notice'" class="dialog-notice">
{{source.msg.notice}}
</div>
<template v-else>
<div class="dialog-avatar">
<UserAvatar :userid="source.userid" :tooltipDisabled="source.userid == userId" :size="30"/>

View File

@ -210,7 +210,7 @@
.nav-tags {
position: absolute;
top: 70px;
top: 74px;
left: 0;
width: 100%;
z-index: 2;
@ -326,11 +326,14 @@
list-style: none;
padding-bottom: 16px;
.dialog-tag {
.dialog-tag,
.dialog-notice {
font-size: 12px;
max-width: 80%;
margin: 0 auto;
padding: 4px 8px;
border-radius: 8px;
color: $primary-desc-color;
background-color: #efefef;
word-wrap: break-word;
cursor: pointer;

View File

@ -5,9 +5,8 @@
<style type="text/css">
.st0{fill:#FFFFFF;}
</style>
<path class="st0" d="M905,334.3c-66-66-198.5-198.5-198.5-198.5c-53.8-53.8-112.3-61.2-152-29.4c-21.3,17-33.3,40.7-36.1,65.2
c-2.8,24.4-17.4,45.8-36.9,60.7l-6.5,5c-90.5,69.2-193.4,126.4-306.2,142.9c-25.2,3.7-49.2,17.1-65.7,40.3
c-28.3,39.7-19.4,95.2,15,129.7l153.3,153.3L133.2,841.8c-13.3,13.3-13.3,34.7,0,48c6.6,6.6,15.3,9.9,24,9.9c8.7,0,17.4-3.3,24-9.9
l138.3-138.3l129.1,129.1c58.8,58.8,113.7,67.5,153.3,39.7c20.1-14.1,33-33.8,38.6-55c27.5-104.2,62.3-206.4,127.2-292.4l23.3-31
c14.8-19.6,36.1-34.5,60.4-37.2c24.6-2.8,48.3-14.8,65.3-36.2C948.4,428.7,940.9,370.2,905,334.3z"/>
<path class="st0" d="M913.8,405.3L618.7,110.2c-31.1-31.1-81.9-31.1-113.1,0L110.2,505.6l0,0c-15.9,15.9-24.4,37.9-23.3,60.3
l13.4,281.7c2,41.4,34.7,74,76.1,76l281.7,13.4c1.2,0,2.5,0.1,3.7,0.1c21.1,0,41.6-8.4,56.6-23.4l395.4-395.4
C945,487.2,945,436.5,913.8,405.3z M390,736.1c-56.3,0-102.1-45.8-102.1-102.1S333.7,531.9,390,531.9c56.3,0,102,45.8,102,102.1
S446.3,736.1,390,736.1z"/>
</svg>

Before

Width:  |  Height:  |  Size: 995 B

After

Width:  |  Height:  |  Size: 797 B

View File

@ -5,9 +5,8 @@
<style type="text/css">
.st0{fill:#9D95E5;}
</style>
<path class="st0" d="M905,334.3c-66-66-198.5-198.5-198.5-198.5c-53.8-53.8-112.3-61.2-152-29.4c-21.3,17-33.3,40.7-36.1,65.2
c-2.8,24.4-17.4,45.8-36.9,60.7l-6.5,5c-90.5,69.2-193.4,126.4-306.2,142.9c-25.2,3.7-49.2,17.1-65.7,40.3
c-28.3,39.7-19.4,95.2,15,129.7l153.3,153.3L133.2,841.8c-13.3,13.3-13.3,34.7,0,48c6.6,6.6,15.3,9.9,24,9.9c8.7,0,17.4-3.3,24-9.9
l138.3-138.3l129.1,129.1c58.8,58.8,113.7,67.5,153.3,39.7c20.1-14.1,33-33.8,38.6-55c27.5-104.2,62.3-206.4,127.2-292.4l23.3-31
c14.8-19.6,36.1-34.5,60.4-37.2c24.6-2.8,48.3-14.8,65.3-36.2C948.4,428.7,940.9,370.2,905,334.3z"/>
<path class="st0" d="M909.9,408.7L614.8,113.6c-31.1-31.1-81.9-31.1-113.1,0L106.3,509l0,0c-15.9,15.9-24.4,37.9-23.3,60.3
l13.4,281.7c2,41.4,34.7,74,76.1,76l281.7,13.4c1.2,0,2.5,0.1,3.7,0.1c21.1,0,41.6-8.4,56.6-23.4l395.4-395.4
C941.1,490.6,941.1,439.9,909.9,408.7z M386.1,739.4c-56.3,0-102.1-45.8-102.1-102.1s45.8-102.1,102.1-102.1
c56.3,0,102,45.8,102,102.1S442.3,739.4,386.1,739.4z"/>
</svg>

Before

Width:  |  Height:  |  Size: 995 B

After

Width:  |  Height:  |  Size: 804 B