fix: 封堵 ask-status domain 枚举、私聊写路径 fail-open、压缩兜底重复提交

三处小修 + 两个格式清理,均来自全盘复查:

1. ask-status domain 枚举:ErrUserNotExists 分支原返回空数组、正常分支返回带元素
   数组,凭空/非空可枚举 domain 是否存在(含被 L1 隐藏或设了页面密码的半公开箱)。
   改为箱主不存在时也回显 ok:false,四种失败响应完全同形。

2. 私聊 SendMessage 写路径用 FeatureStateOf(fail-open 变体):读配置失败会回退默认值,
   与「写路径必须 FeatureStateOfStrict(失败即拒)」的约定不符。此前靠 chat 默认关闭
   的巧合侥幸安全,现统一改 Strict。

3. 图片压缩 submit 兜底可重复提交:capture 监听器里 tbBeginSubmit 从 Promise 回调提前
   到 preventDefault 同步栈,物理阻止压缩窗口内双击重复提交。

顺带:box_views.go / message_image.go / insights 两个文件补末尾换行与 struct 字段对齐
(gofmt 干净)。
This commit is contained in:
tamakyi
2026-10-29 18:52:38 +08:00
parent c9b426acbb
commit 693b1102c2
8 changed files with 95 additions and 26 deletions
+8 -2
View File
@@ -88,8 +88,14 @@ func AskStatusAPI(ctx context.Context) error {
owner, err := db.Users.GetByDomain(ctx.Request().Context(), req.Domain)
if err != nil {
if errors.Is(err, db.ErrUserNotExists) {
// 不区分「箱主不存在」与「提问不属于他」:一律返回空结果。
return ctx.JSON(map[string]interface{}{"items": []askStatusResult{}})
// 箱主不存在时,也按请求的 items 原样回显 ok=false,与「箱主存在但
// 校验失败」保持完全同形。否则「空数组 vs 带元素数组」会泄露 domain
// 是否存在(含被 L1 从探索页隐藏、或设了页面密码的半公开箱)。
out := make([]askStatusResult, 0, len(req.Items))
for _, it := range req.Items {
out = append(out, askStatusResult{ID: it.ID})
}
return ctx.JSON(map[string]interface{}{"items": out})
}
logrus.WithContext(ctx.Request().Context()).WithError(err).Error("Failed to get box owner for ask status")
return ctx.ServerError()