fix(chat): 删除会话时保留后台聊天记录
- 会话列表和操作排除软删除记录,保留全部历史消息供后台查看 - 新增 018 数据库迁移及管理员删除状态字段 - 补齐删除后访问边界回归并同步迁移文档
This commit is contained in:
@@ -139,7 +139,7 @@ export async function digitalRoutes(app: FastifyInstance) {
|
||||
front.get("/conversations", async (r) =>
|
||||
ok(
|
||||
await rows(
|
||||
"SELECT id,character_id AS characterId,title,updated_at AS updatedAt FROM dh_conversations WHERE account=? ORDER BY updated_at DESC LIMIT 100",
|
||||
"SELECT id,character_id AS characterId,title,updated_at AS updatedAt FROM dh_conversations WHERE account=? AND deleted_at IS NULL ORDER BY updated_at DESC LIMIT 100",
|
||||
[r.user.sub],
|
||||
),
|
||||
),
|
||||
@@ -228,13 +228,9 @@ export async function digitalRoutes(app: FastifyInstance) {
|
||||
new Date(conversation.lease_until).getTime() > Date.now()
|
||||
)
|
||||
throw conflict("请先停止生成");
|
||||
// 前台删除仅隐藏会话,保留消息、分支和后台审计所需的历史记录。
|
||||
await write(
|
||||
"DELETE FROM dh_messages WHERE conversation_id=?",
|
||||
[id],
|
||||
c,
|
||||
);
|
||||
await write(
|
||||
"DELETE FROM dh_conversations WHERE id=? AND account=?",
|
||||
"UPDATE dh_conversations SET deleted_at=NOW(3) WHERE id=? AND account=? AND deleted_at IS NULL",
|
||||
[id, r.user.sub],
|
||||
c,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user