feat(moderation): add user profile content moderation for avatars, covers, and bios
This commit is contained in:
@@ -11,11 +11,15 @@ import (
|
||||
type AuditTargetType string
|
||||
|
||||
const (
|
||||
AuditTargetTypePost AuditTargetType = "post" // 帖子
|
||||
AuditTargetTypeComment AuditTargetType = "comment" // 评论
|
||||
AuditTargetTypeMessage AuditTargetType = "message" // 私信
|
||||
AuditTargetTypeUser AuditTargetType = "user" // 用户资料
|
||||
AuditTargetTypeImage AuditTargetType = "image" // 图片
|
||||
AuditTargetTypePost AuditTargetType = "post" // 帖子
|
||||
AuditTargetTypeComment AuditTargetType = "comment" // 评论
|
||||
AuditTargetTypeMessage AuditTargetType = "message" // 私信
|
||||
AuditTargetTypeUser AuditTargetType = "user" // 用户资料
|
||||
AuditTargetTypeImage AuditTargetType = "image" // 图片
|
||||
AuditTargetTypeAvatar AuditTargetType = "avatar" // 头像
|
||||
AuditTargetTypeCover AuditTargetType = "cover" // 背景图
|
||||
AuditTargetTypeBio AuditTargetType = "bio" // 个性签名
|
||||
AuditTargetTypeUserProfile AuditTargetType = "user_profile" // 用户资料审核任务
|
||||
)
|
||||
|
||||
// AuditResult 审核结果
|
||||
|
||||
@@ -173,6 +173,9 @@ func autoMigrate(db *gorm.DB) error {
|
||||
|
||||
// 身份认证相关
|
||||
&VerificationRecord{},
|
||||
|
||||
// 用户资料审核相关
|
||||
&UserProfileAudit{},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
51
internal/model/user_profile_audit.go
Normal file
51
internal/model/user_profile_audit.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type UserProfileContentType string
|
||||
|
||||
const (
|
||||
UserProfileContentTypeAvatar UserProfileContentType = "avatar"
|
||||
UserProfileContentTypeCover UserProfileContentType = "cover"
|
||||
UserProfileContentTypeBio UserProfileContentType = "bio"
|
||||
)
|
||||
|
||||
type UserProfileAuditStatus string
|
||||
|
||||
const (
|
||||
UserProfileAuditStatusPending UserProfileAuditStatus = "pending"
|
||||
UserProfileAuditStatusApproved UserProfileAuditStatus = "approved"
|
||||
UserProfileAuditStatusRejected UserProfileAuditStatus = "rejected"
|
||||
)
|
||||
|
||||
type UserProfileAudit struct {
|
||||
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
UserID string `json:"user_id" gorm:"type:varchar(36);index;not null"`
|
||||
ContentType UserProfileContentType `json:"content_type" gorm:"type:varchar(20);index;not null"`
|
||||
Content string `json:"content" gorm:"type:text;not null"`
|
||||
Status UserProfileAuditStatus `json:"status" gorm:"type:varchar(20);default:pending;index"`
|
||||
ReviewedAt *time.Time `json:"reviewed_at" gorm:"type:timestamp"`
|
||||
ReviewedBy string `json:"reviewed_by" gorm:"type:varchar(50)"`
|
||||
RejectReason string `json:"reject_reason" gorm:"type:text"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||
|
||||
User *User `json:"user" gorm:"foreignKey:UserID"`
|
||||
}
|
||||
|
||||
func (a *UserProfileAudit) BeforeCreate(tx *gorm.DB) error {
|
||||
if a.ID == "" {
|
||||
a.ID = uuid.New().String()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (UserProfileAudit) TableName() string {
|
||||
return "user_profile_audits"
|
||||
}
|
||||
Reference in New Issue
Block a user