chore: baseline snapshot before moderation-strictness feature

Repo .git was damaged (refs/ missing, index truncated, object store near-empty).
Repaired via git init (rebuilt refs), stale index preserved as .git/index.corrupt-20260910.bak,
then full worktree committed as a rollback baseline.
This commit is contained in:
tamakyi
2026-09-10 10:56:27 +08:00
commit e3e59e7c69
296 changed files with 67458 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
package shared
import "strings"
// BlockWordHit 检查文本是否命中箱主设置的屏蔽词表(逗号分隔),返回首个命中的词。
//
// 屏蔽词语义为「箱主防骚扰词表」:提问、私聊(对方发给我的消息)与投票提交的
// 开放文本都应经过同一份词表过滤,因此把判定收敛到本函数供各入口复用,
// 与账号设置页保存时使用的同一 CSV 格式(半角逗号分隔、已去重、去空白)。
//
// 存储层可能残留历史脏数据(多余空白 / 空项),这里解析时统一 TrimSpace 并跳过空项。
func BlockWordHit(blockWordsCSV, text string) (word string, hit bool) {
if blockWordsCSV == "" || text == "" {
return "", false
}
for _, w := range strings.Split(blockWordsCSV, ",") {
w = strings.TrimSpace(w)
if w == "" {
continue
}
if strings.Contains(text, w) {
return w, true
}
}
return "", false
}