fix v13
This commit is contained in:
@@ -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 != "" {
|
||||
|
||||
Reference in New Issue
Block a user