feat(nsfw): 持久化账号偏好并接入生成控制
- digital.profile.ts: 未保存偏好时默认开启,原子合并 JSON 保留其他资料 - digital.controller.ts、digital.users.ts: 接入本人和管理员偏好读写、事务及审计 - digital.chat.ts、digital.prompt.ts、digital.suggestions.ts: 各生成入口读取服务端账号偏好,保留游客鉴权 - tests/digital-*.test.ts: 覆盖默认值、关闭保留、旧客户端兼容与越权拦截 - README.md: 同步模块职责和发布要求
This commit is contained in:
@@ -79,3 +79,28 @@ test("灵感接口不接受匿名用户,即使请求体伪造账号也会先
|
||||
await app.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("回复灵感遵循账号开关,关闭时保留日常内容限制", () => {
|
||||
for (const nsfwEnabled of [true, false]) {
|
||||
const messages = replyIdeasMessages({
|
||||
name: "角色",
|
||||
description: "",
|
||||
scenario: "",
|
||||
userName: "旅人",
|
||||
persona: "",
|
||||
memory: "",
|
||||
draft: "",
|
||||
lore: [],
|
||||
history: [],
|
||||
nsfwEnabled,
|
||||
});
|
||||
assert.ok(
|
||||
messages[0].content.includes(nsfwEnabled ? "NSFW 已开启" : "NSFW 已关闭"),
|
||||
);
|
||||
assert.match(messages[0].content, /禁止涉及未成年人的性内容/);
|
||||
assert.equal(
|
||||
messages[0].content.includes("不生成露骨性描写"),
|
||||
!nsfwEnabled,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user