feat(todo): 聊天待办支持提醒时间(到点引用原消息+@提及)

给消息待办增加可选「提醒时间」,到点由 todo-alert 机器人对原消息发起
reply、正文 @ 仍在群内的被指派成员,完全复用原生回复/提及链路(定向未读、
红点、绕过会话免打扰、App 推送);被指派人全部退群则跳过发送并标记已提醒。
设/改/取消提醒的权限沿用 todo_set_permission 开关与 checkTodoOwnerPermission。

后端:
- 迁移:web_socket_dialog_msg_todos 增加 remind_at/reminded_at 及索引,
  注册为日期字段
- WebSocketDialogMsgTodo::dueReminders() 选取到点(未提醒/未完成)待办(limit 500)
- WebSocketDialogMsg::setTodoRemind() 纯数据写入(改时间重置 reminded_at),
  接入 toggleTodoMsg($remindAt) 与 msg__todo 透传
- 接口 msg__todoremind 设置/修改/取消提醒(权限闸门、消息类型校验、
  pushMsg 同步 todo_done)
- TodoRemindTask 到点按消息发提醒(reminded_at 防重复、迟发补发、原消息/
  会话删除兜底),buildRemindText 生成 <span class="mention user"> 文本,
  接入 crontab;登记 todo-alert 机器人
- msgJoinGroup 从提醒文本中提取被 @ 成员

前端:
- 设待办弹窗新增「提醒时间」(预设 + 自定义 DatePicker)
- 待办详情浮层每条待办可查看/修改/取消提醒:DatePicker on-clear「清空」
  二次确认后取消,无时间时仅关闭面板不发请求
- 待办浮层窄屏(≤500px)改为 待办/完成 tab 切换,宽屏维持双列;列表为空
  展示空状态占位;提醒时间用 Icon 替换 emoji
- 时间读写对齐项目任务时间的时区约定

测试:tests/Feature/TodoRemindTest(数据/选取/写入/权限决策/buildRemindText/
text mention 提取),TodoSetPermissionTest 无回归。

任务 #124 后续增强。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
kuaifan
2026-06-01 12:08:34 +00:00
co-authored by Claude Opus 4.8
parent adc7fb0d07
commit 6b54b7b1c5
14 changed files with 716 additions and 13 deletions
+61 -1
View File
@@ -1670,6 +1670,7 @@ class DialogController extends AbstractController
if (!in_array($botType, [
'system-msg',
'task-alert',
'todo-alert',
'check-in',
'approval-alert',
'meeting-alert',
@@ -2571,7 +2572,8 @@ class DialogController extends AbstractController
} else {
$userids = is_array($userids) ? $userids : [];
}
return $msg->toggleTodoMsg($user->userid, $userids);
$remindAt = Request::exists('remind_at') ? (trim(Request::input('remind_at', '')) ?: null) : false;
return $msg->toggleTodoMsg($user->userid, $userids, $remindAt);
}
/**
@@ -2604,6 +2606,64 @@ class DialogController extends AbstractController
return Base::retSuccess('success', $todo ?: []);
}
/**
* @api {post} api/dialog/msg/todoremind 设置/修改/取消待办提醒时间
*
* @apiDescription 需要token身份
* @apiVersion 1.0.0
* @apiGroup dialog
* @apiName msg__todoremind
*
* @apiParam {Number} msg_id 消息ID
* @apiParam {Array} userids 目标成员ID组
* @apiParam {String} remind_at 提醒时间(空表示取消提醒)
*
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
* @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据
*/
public function msg__todoremind()
{
$user = User::auth();
//
$msg_id = intval(Request::input("msg_id"));
$userids = Request::input('userids');
$userids = is_array($userids) ? array_values(array_filter(array_map('intval', $userids))) : [];
$remindAt = trim(Request::input('remind_at', '')) ?: null;
//
$msg = WebSocketDialogMsg::whereId($msg_id)->first();
if (empty($msg)) {
return Base::retError("消息不存在或已被删除");
}
if (in_array($msg->type, ['tag', 'todo', 'notice'])) {
return Base::retError('此消息不支持设待办');
}
$dialog = WebSocketDialog::checkDialog($msg->dialog_id);
//
if (empty($userids)) {
return Base::retError("请选择成员");
}
// 权限管控(与设/取消待办同一开关与放行规则)
if (Base::settingFind('system', 'todo_set_permission') === 'close') {
$others = array_diff($userids, [$user->userid]);
if ($others && !$dialog->checkTodoOwnerPermission($user->userid)) {
return Base::retError('仅群主、项目/任务负责人可设置或取消他人待办');
}
}
//
$msg->setTodoRemind($userids, $remindAt);
//
$upData = [
'id' => $msg->id,
'todo' => $msg->todo,
'todo_done' => $msg->isTodoDone(true),
'dialog_id' => $msg->dialog_id,
];
$dialog->pushMsg('update', $upData);
//
return Base::retSuccess($remindAt ? '设置成功' : '取消成功', $upData);
}
/**
* @api {get} api/dialog/msg/done 完成待办
*