Files
tamabox/internal/form/question.go
T
2026-10-18 22:18:21 +08:00

50 lines
2.4 KiB
Go

// Copyright 2022 E99p1ant. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package form
import (
"mime/multipart"
)
// 注意:以下结构体的 Content / Answer 字段刻意不再带 govalid 的 maxlen 标签 ——
// struct tag 是编译期常量,无法跟随 conf/app.ini 的 [limits] 段调整(历史上写死 2000,
// 与前端 maxlength 不一致且无法调参)。长度上限改由各路由 handler 读取
// conf.Limits.QuestionContentLen / AnswerContentLen / FollowUpContentLen 做 rune 校验。
type NewQuestion struct {
Content string `form:"content" valid:"required" label:"问题内容" msg:"form.question.content"`
ReceiveReplyViaEmail string
ReceiveReplyEmail string `valid:"email;maxlen:254" label:"接收回复的电子邮箱" msg:"form.question.receiveReplyEmail"`
Recaptcha string `form:"g-recaptcha-response" valid:"required" label:"Recaptcha" msg:"form.recaptcha"`
Images []*multipart.FileHeader `form:"images" label:"图片"`
IsPrivate string `form:"private"`
AskPassword string `form:"ask_password" label:"提问密码"`
StartChat string `form:"start_chat_val"`
}
type PublishAnswerQuestion struct {
Answer string `form:"answer" valid:"required" label:"回答内容" msg:"form.answer.content"`
Images []*multipart.FileHeader `form:"images" label:"图片"`
}
type UpdateAnswerQuestion struct {
Answer string `form:"answer" valid:"required" label:"回答内容" msg:"form.answer.content"`
Images []*multipart.FileHeader `form:"images" label:"图片"`
}
type PublishFollowUpQuestion struct {
Content string `form:"content" valid:"required" label:"追问内容" msg:"form.followup.content"`
Token string `form:"token"`
}
type AnswerFollowUpQuestion struct {
Answer string `form:"answer" valid:"required" label:"追问回答" msg:"form.followup.answer"`
}
// ReportQuestion 举报单条内容。理由只接受固定枚举(见 db.IsValidReportReason),
// 不做自由文本 —— 否则举报框本身就成了新的辱骂输入口。
type ReportQuestion struct {
Reason string `form:"reason" valid:"required;maxlen:32" label:"举报理由" msg:"report.errInvalidReason"`
}