perf: 新任务提醒区分协助还是负责

This commit is contained in:
kuaifan 2024-10-27 11:11:18 +08:00
parent a6acb7ea0d
commit c23de08cf5

View File

@ -1686,15 +1686,6 @@ class ProjectTask extends AbstractModel
if (empty($botUser)) { if (empty($botUser)) {
return; return;
} }
$dataId = $this->parent_id ?: $this->id;
$text = match ($type) {
1 => "(*)即将超时",
2 => "(*)已经超时",
3 => "(*)时间已修改",
default => "您有一个新任务",
};
/** @var User $user */ /** @var User $user */
foreach ($receivers as $receiver) { foreach ($receivers as $receiver) {
$data = [ $data = [
@ -1705,17 +1696,31 @@ class ProjectTask extends AbstractModel
if (in_array($type, [1, 2]) && ProjectTaskPushLog::where($data)->exists()) { if (in_array($type, [1, 2]) && ProjectTaskPushLog::where($data)->exists()) {
continue; continue;
} }
if ($owners[$receiver->userid]) {
$title = match ($type) {
1 => "您负责的任务即将超时",
2 => "您负责的任务已经超时",
3 => "您负责的任务时间已修改",
default => "您有一个新任务",
};
} else {
$title = match ($type) {
1 => "您协助的任务即将超时",
2 => "您协助的任务已经超时",
3 => "您协助的任务时间已修改",
default => "您有一个新协助任务",
};
}
// //
$replace = $owners[$receiver->userid] ? "您负责的任务" : "您协助的任务";
$dialog = WebSocketDialog::checkUserDialog($botUser, $receiver->userid); $dialog = WebSocketDialog::checkUserDialog($botUser, $receiver->userid);
if ($dialog) { if ($dialog) {
ProjectTaskPushLog::createInstance($data)->save(); ProjectTaskPushLog::createInstance($data)->save();
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [ WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [
'type' => 'task_list', 'type' => 'task_list',
'title' => str_replace("(*)", $replace, $text) . $suffix, 'title' => $title . $suffix,
'list' => [ 'list' => [
[ [
'id' => $dataId, 'id' => $this->parent_id ?: $this->id,
'name' => $this->name, 'name' => $this->name,
] ]
], ],