feat(moderation): add user profile content moderation for avatars, covers, and bios
This commit is contained in:
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