aliyun sensor server
This commit is contained in:
+29
-3
@@ -37,6 +37,9 @@ type UsersStore interface {
|
||||
// 提问/私聊/投票三个面板共用一份),必须分开写,避免单侧保存误清空另一侧。
|
||||
UpdateHarassmentType(ctx context.Context, id uint, typ HarassmentSettingType) error
|
||||
UpdateBlockWords(ctx context.Context, id uint, words string) error
|
||||
// UpdateModerationStrictness 更新内容审核严格度(lax / standard / strict,空值表示跟随站点默认)。
|
||||
// 只写 moderation_strictness 列,不影响防骚扰与屏蔽词。
|
||||
UpdateModerationStrictness(ctx context.Context, id uint, strictness string) error
|
||||
Authenticate(ctx context.Context, email, password string) (*User, error)
|
||||
ChangePassword(ctx context.Context, id uint, oldPassword, newPassword string) error
|
||||
UpdatePassword(ctx context.Context, id uint, newPassword string) error
|
||||
@@ -104,9 +107,15 @@ type User struct {
|
||||
Notify NotifyType `json:"notify"`
|
||||
HarassmentSetting HarassmentSettingType `json:"harassment_setting"`
|
||||
BlockWords string `json:"-"`
|
||||
Tags string `json:"tags" gorm:"type:text"`
|
||||
ShowInHome bool `json:"show_in_home" gorm:"default:false;index"`
|
||||
UseCustomQRColor bool `json:"use_custom_qr_color" gorm:"default:false"`
|
||||
// ModerationStrictness 内容审核严格度:lax / standard / strict。
|
||||
// 空值表示「跟随站点默认」([security] default_moderation_strictness),
|
||||
// 存量账号迁移后即为空值形态 —— 缺省回退 strict(最严档),
|
||||
// 保证引入该字段这一动作不会放宽任何账号的拦截面。
|
||||
// 取值解释与裁决逻辑见 internal/security/censor/policy.go。
|
||||
ModerationStrictness string `json:"-" gorm:"column:moderation_strictness;type:varchar(16);default:''"`
|
||||
Tags string `json:"tags" gorm:"type:text"`
|
||||
ShowInHome bool `json:"show_in_home" gorm:"default:false;index"`
|
||||
UseCustomQRColor bool `json:"use_custom_qr_color" gorm:"default:false"`
|
||||
|
||||
PagePassword string `json:"-" gorm:"column:page_password;type:varchar(255);default:''"`
|
||||
AskPassword string `json:"-" gorm:"column:ask_password;type:varchar(255);default:''"`
|
||||
@@ -390,6 +399,23 @@ func (db *users) UpdateBlockWords(ctx context.Context, id uint, words string) er
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateModerationStrictness 仅更新内容审核严格度。
|
||||
// 只写 moderation_strictness 列,不动 harassment_setting 与 block_words,
|
||||
// 避免三个独立设置面板互相覆盖。
|
||||
//
|
||||
// 取值合法性由上层(route/user)在写入前校验。此处不再二次校验是有意为之:
|
||||
// 本包不能 import internal/security/censor(后者要读 censor_logs,反向依赖本包,
|
||||
// 会形成 import 环)。即便绕过上层写入脏值也不会有安全问题——解析层的
|
||||
// censor.ParseStrictness 对未知取值回退「严格」档,方向是保守的(见 policy.go)。
|
||||
func (db *users) UpdateModerationStrictness(ctx context.Context, id uint, strictness string) error {
|
||||
if err := db.WithContext(ctx).Model(&User{}).Where("id = ?", id).Updates(map[string]interface{}{
|
||||
"ModerationStrictness": strictness,
|
||||
}).Error; err != nil {
|
||||
return errors.Wrap(err, "update user")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db *users) Authenticate(ctx context.Context, email, password string) (*User, error) {
|
||||
u, err := db.GetByEmail(ctx, email)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user