This commit is contained in:
tamakyi
2026-10-19 02:25:19 +08:00
parent 4592b6ef24
commit 12a37e726f
14 changed files with 315 additions and 5 deletions
+32
View File
@@ -144,6 +144,38 @@ func SendQuestionReportedMail(email, domain string, questionID uint, count int64
return sendTemplateMail(email, "【狼的提问箱】你的内容被举报了", templates.FS, "mail/question-reported.html", params)
}
// RestrictionNotice 处置通知邮件的内容。
//
// 全部文案由调用方按「箱主自己的界面语言」预先翻译好再传进来:
// 邮件模板本身是单语言的,而箱主的语言存在 users.language 里,只能在调用侧解析。
//
// 刻意不包含 --reason 原文:那是运维的审计备注(可能写得很直白),
// 对外只用「级别 + 到期时间 + 规则链接」,与公告模板的口径一致。
type RestrictionNotice struct {
To string
Heading string
Greeting string
Body string
Note string
RulesText string
RulesURL string
Appeal string
}
// SendRestrictionNoticeMail 告知箱主「你的提问箱已被限制」。
func SendRestrictionNoticeMail(n RestrictionNotice) error {
params := map[string]string{
"heading": n.Heading,
"greeting": n.Greeting,
"body": n.Body,
"note": n.Note,
"rulesText": n.RulesText,
"rulesURL": n.RulesURL,
"appeal": n.Appeal,
}
return sendTemplateMail(n.To, n.Heading, templates.FS, "mail/restriction-notice.html", params)
}
func sendTemplateMail(email, title string, templateFS embed.FS, templatePath string, params map[string]string) error {
var content bytes.Buffer
t, err := template.ParseFS(templateFS, templatePath)