restrict v9

This commit is contained in:
tamakyi
2026-10-18 23:48:57 +08:00
parent 7a6417c33d
commit 7e0e1cba49
5 changed files with 38 additions and 3 deletions
+27
View File
@@ -364,3 +364,30 @@ admin6 当前处于 L2(到期次日),必要时 `unrestrict` 解除。
⚠️ 文案由我起草,**需用户过目**(尤其对外承诺的措辞)。
验证:`go build ./...` EXIT=0;`checktpl` OK;`TestReports`/`TestRestrictions` 全绿。
### 部署后验证:3 项通过,1 项 500 待查
- ✅ 处置期条幅:登录 admin6 的 `/user/questions` 出现「限制期」文案(1 处);
- ✅ 举报 badge:「被举报 1 次」;
- ✅ 闭环:`POST /set-private` → badge 归 0、公开页不再出现 73;
`set-public` 返回 200(不是 302)是**预期** —— L2 禁止设公开,不是 bug。73 现处于私密,需先 `unrestrict` 才能恢复。
- ❌ **`/rules` 返回 500**(其余公开页 `/`、`/about-me`、`/sponsor`、`/deactivated` 均 200)。
已在本地排除:模板语法 checktpl 通过、i18n 四语言键齐全(grep 确认在 map 内)、`t` 函数返回 string 不抛错。
**待用户提供服务端日志**(500 只回 22 字节 "Internal Server Error",无细节)。
顺带修掉一个**我引入的回归**:`templates/render_test.go` 的 `mockItem` 缺 `ReportCount`,
导致 `user/question-list` 渲染测试失败(`can't evaluate field ReportCount in type interface {}`)。
已补字段;同时把 `{{ if gt .ReportCount 0 }}` 改为 `{{ if .ReportCount }}`(更宽容,零值即假)。
`go test ./templates/` 恢复全绿。
### /rules 500 根因:模板没进 embed 清单
日志:`template: rendering error="html/template: \"rules\" is undefined"`。
**`templates/embed.go` 是显式文件清单**(并非我原先以为的整目录 embed)。新增的顶层
`rules.html` 没写进 `//go:embed ...` 那行 → 没被打包 → `ctx.Success("rules")` 找不到模板 → 500。
编译、checktpl、单测全部无感(测试不渲染该页),只有实际访问才炸。
已把 `rules.html` 加进清单,编译 EXIT=0、`go test ./templates/` 通过。
⚠️ 以后新增**顶层**模板必须改 embed 指令;子目录下的文件已被目录项覆盖。
MEMORY.md 里那条错误认知已纠正。