This commit is contained in:
tamakyi
2026-10-19 01:58:00 +08:00
parent bd613a6f5a
commit 4592b6ef24
14 changed files with 608 additions and 244 deletions
@@ -45,6 +45,17 @@ func StrictnessFor(raw string) censor.Strictness {
// 处置查询失败时**回退账号自身设置**,而不是"失败即强制 strict":
// DB 抖动时反向兜底会让全站突然加严,正常用户的提交被大面积误拒,
// 影响面远大于「漏放一个受控账号」。
// EffectiveStrictnessFor 是 EffectiveStrictness 的「已持有处置级别」版本。
//
// 调用方在同一请求里已经查过 ActiveLevel(例如发布前的 L2/L3 拦截)时用它,
// 避免为同一份状态重复打库。
func EffectiveStrictnessFor(level db.RestrictionLevel, raw string) censor.Strictness {
if level != "" {
return censor.StrictnessStrict
}
return StrictnessFor(raw)
}
func EffectiveStrictness(ctx context.Context, userID uint, raw string) censor.Strictness {
if userID != 0 {
if level, _, err := db.Restrictions.ActiveLevel(ctx, userID); err == nil && level != "" {