mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-07 09:57:37 +00:00
perf: 优化任务提醒
This commit is contained in:
parent
81e4220367
commit
d5d9eb93a3
@ -769,7 +769,7 @@ class ProjectTask extends AbstractModel
|
||||
]);
|
||||
$this->taskPush(null, 3);
|
||||
}
|
||||
// 以下紧顶级任务可修改
|
||||
// 以下仅顶级任务可修改
|
||||
if ($this->parent_id === 0) {
|
||||
// 重复周期
|
||||
$loopAt = $this->loop_at;
|
||||
@ -1444,6 +1444,7 @@ class ProjectTask extends AbstractModel
|
||||
if (empty($userids)) {
|
||||
return;
|
||||
}
|
||||
$owners = $this->taskUser->pluck('owner', 'userid')->toArray();
|
||||
$users = User::whereIn('userid', $userids)->whereNull('disable_at')->get();
|
||||
if (empty($users)) {
|
||||
return;
|
||||
@ -1454,10 +1455,13 @@ class ProjectTask extends AbstractModel
|
||||
return;
|
||||
}
|
||||
|
||||
$text = view('push.task', [
|
||||
'type' => str_replace([0, 1, 2, 3], ['start', 'before', 'after', 'times'], $type),
|
||||
'task' => $this,
|
||||
])->render();
|
||||
$taskHtml = "<span class=\"mention task\" data-id=\"{$this->id}\">#{$this->name}</span>";
|
||||
$text = match ($type) {
|
||||
1 => "您的任务 {$taskHtml} 即将超时。",
|
||||
2 => "您的任务 {$taskHtml} 已经超时。",
|
||||
3 => "您的任务 {$taskHtml} 时间已修改。",
|
||||
default => "您有一个新任务 {$taskHtml}。",
|
||||
};
|
||||
|
||||
/** @var User $user */
|
||||
foreach ($users as $user) {
|
||||
@ -1471,10 +1475,13 @@ class ProjectTask extends AbstractModel
|
||||
continue;
|
||||
}
|
||||
//
|
||||
$replace = $owners[$user->userid] ? "您负责的任务" : "您协助的任务";
|
||||
$dialog = WebSocketDialog::checkUserDialog($botUser->userid, $data['userid']);
|
||||
if ($dialog) {
|
||||
ProjectTaskPushLog::createInstance($data)->save();
|
||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', ['text' => $text], $botUser->userid);
|
||||
WebSocketDialogMsg::sendMsg(null, $dialog->id, 'text', [
|
||||
'text' => str_replace("您的任务", $replace, $text)
|
||||
], $botUser->userid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
@if ($type === 'before')
|
||||
您的任务 <span class="mention task" data-id="{{ $task->id }}">#{{ $task->name }}</span> 即将超时,请及时处理。
|
||||
@elseif ($type === 'after')
|
||||
您的任务 <span class="mention task" data-id="{{ $task->id }}">#{{ $task->name }}</span> 已经超时,请及时处理。
|
||||
@elseif ($type === 'times')
|
||||
您的任务 <span class="mention task" data-id="{{ $task->id }}">#{{ $task->name }}</span> 时间已修改,请注意查看。
|
||||
@else
|
||||
您有一个新任务 <span class="mention task" data-id="{{ $task->id }}">#{{ $task->name }}</span>。
|
||||
@endif
|
||||
Loading…
x
Reference in New Issue
Block a user