From c23de08cf5d0b9f900f96ad2b1160ce7bfcba247 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sun, 27 Oct 2024 11:11:18 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=96=B0=E4=BB=BB=E5=8A=A1=E6=8F=90?= =?UTF-8?q?=E9=86=92=E5=8C=BA=E5=88=86=E5=8D=8F=E5=8A=A9=E8=BF=98=E6=98=AF?= =?UTF-8?q?=E8=B4=9F=E8=B4=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/ProjectTask.php | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/app/Models/ProjectTask.php b/app/Models/ProjectTask.php index 4aee39c86..273ba2da5 100644 --- a/app/Models/ProjectTask.php +++ b/app/Models/ProjectTask.php @@ -1686,15 +1686,6 @@ class ProjectTask extends AbstractModel if (empty($botUser)) { return; } - - $dataId = $this->parent_id ?: $this->id; - $text = match ($type) { - 1 => "(*)即将超时", - 2 => "(*)已经超时", - 3 => "(*)时间已修改", - default => "您有一个新任务", - }; - /** @var User $user */ foreach ($receivers as $receiver) { $data = [ @@ -1705,17 +1696,31 @@ class ProjectTask extends AbstractModel if (in_array($type, [1, 2]) && ProjectTaskPushLog::where($data)->exists()) { 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); if ($dialog) { ProjectTaskPushLog::createInstance($data)->save(); WebSocketDialogMsg::sendMsg(null, $dialog->id, 'template', [ 'type' => 'task_list', - 'title' => str_replace("(*)", $replace, $text) . $suffix, + 'title' => $title . $suffix, 'list' => [ [ - 'id' => $dataId, + 'id' => $this->parent_id ?: $this->id, 'name' => $this->name, ] ],