fix: 修复头像审核旧图裂开问题 + CSP 配置修复
- 头像提交审核不再删除旧文件,审核通过后才删除旧头像文件 - 头像审核被拒时删除已上传的新头像文件,保留旧头像 - CSP style-src 移除 nonce 以启用 unsafe-inline(JS 动态样式需要) - CSP script-src 移除 nonce 改用 unsafe-inline + unsafe-eval(Vditor 编辑器和动态样式需要)
This commit is contained in:
@ -48,6 +48,12 @@ type energyRenameRefunder interface {
|
||||
RefundOnRenameReject(userID uint) error
|
||||
}
|
||||
|
||||
// avatarFileCleaner 头像审核通过/拒绝时清理头像文件的接口(ISP)
|
||||
type avatarFileCleaner interface {
|
||||
CleanOldAvatars(userID uint)
|
||||
DeleteAvatarFile(url string) error
|
||||
}
|
||||
|
||||
// AuditService 审核业务逻辑
|
||||
type AuditService struct {
|
||||
auditRepo auditRepo
|
||||
@ -57,6 +63,7 @@ type AuditService struct {
|
||||
notifier auditNotifier
|
||||
levelSvc auditTaskCompleter
|
||||
energyRefundSvc energyRenameRefunder
|
||||
avatarCleaner avatarFileCleaner
|
||||
}
|
||||
|
||||
// NewAuditService 构造函数
|
||||
@ -77,6 +84,12 @@ func (s *AuditService) WithEnergyRefundService(svc energyRenameRefunder) *AuditS
|
||||
return s
|
||||
}
|
||||
|
||||
// WithAvatarFileCleaner 链式注入头像文件清理服务
|
||||
func (s *AuditService) WithAvatarFileCleaner(svc avatarFileCleaner) *AuditService {
|
||||
s.avatarCleaner = svc
|
||||
return s
|
||||
}
|
||||
|
||||
// ShouldAudit 判断指定用户是否需要走审核流程
|
||||
// 规则:admin 及以上角色免审
|
||||
func (s *AuditService) ShouldAudit(userID uint) (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user