feat(config): add sensitive word filtering system with database support
Implement sensitive word filtering feature with configurable database and Redis support. Add security enhancements including WebSocket origin validation, improved password strength requirements, timing attack prevention, and production JWT secret validation. Add batch operation validation limits and optimize user blocking queries with subqueries. BREAKING CHANGE: Password validation now requires minimum 8 characters with uppercase, lowercase, and digit (was 6-50 characters without complexity requirements)
This commit is contained in:
@@ -20,11 +20,11 @@ const (
|
||||
|
||||
// Post 帖子实体
|
||||
type Post struct {
|
||||
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
UserID string `json:"user_id" gorm:"type:varchar(36);index;index:idx_posts_user_status_created,priority:1;not null"`
|
||||
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
UserID string `json:"user_id" gorm:"type:varchar(36);index;index:idx_posts_user_status_created,priority:1;not null"`
|
||||
ChannelID *string `json:"channel_id,omitempty" gorm:"type:varchar(36);index"`
|
||||
Title string `json:"title" gorm:"type:varchar(200);not null"`
|
||||
Content string `json:"content" gorm:"type:text;not null"`
|
||||
Title string `json:"title" gorm:"type:varchar(200);not null"`
|
||||
Content string `json:"content" gorm:"type:text;not null"`
|
||||
|
||||
// 关联
|
||||
// User 需要参与缓存序列化;否则列表命中缓存后会丢失作者信息,前端退化为“匿名用户”
|
||||
@@ -38,11 +38,11 @@ type Post struct {
|
||||
RejectReason string `json:"reject_reason" gorm:"type:varchar(500)"`
|
||||
|
||||
// 统计
|
||||
LikesCount int `json:"likes_count" gorm:"column:likes_count;default:0"`
|
||||
CommentsCount int `json:"comments_count" gorm:"column:comments_count;default:0"`
|
||||
FavoritesCount int `json:"favorites_count" gorm:"column:favorites_count;default:0"`
|
||||
SharesCount int `json:"shares_count" gorm:"column:shares_count;default:0"`
|
||||
ViewsCount int `json:"views_count" gorm:"column:views_count;default:0"`
|
||||
LikesCount int `json:"likes_count" gorm:"column:likes_count;default:0"`
|
||||
CommentsCount int `json:"comments_count" gorm:"column:comments_count;default:0"`
|
||||
FavoritesCount int `json:"favorites_count" gorm:"column:favorites_count;default:0"`
|
||||
SharesCount int `json:"shares_count" gorm:"column:shares_count;default:0"`
|
||||
ViewsCount int `json:"views_count" gorm:"column:views_count;default:0"`
|
||||
|
||||
// 置顶/锁定
|
||||
IsPinned bool `json:"is_pinned" gorm:"default:false"`
|
||||
@@ -78,7 +78,7 @@ func (Post) TableName() string {
|
||||
// PostImage 帖子图片
|
||||
type PostImage struct {
|
||||
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
||||
PostID string `json:"post_id" gorm:"type:varchar(36);index;not null"`
|
||||
PostID string `json:"post_id" gorm:"type:varchar(36);not null;index:idx_post_images_post_sort,priority:1"`
|
||||
URL string `json:"url" gorm:"type:text;not null"`
|
||||
ThumbnailURL string `json:"thumbnail_url" gorm:"type:text"`
|
||||
PreviewURL string `json:"preview_url" gorm:"type:text"` // 列表/网格预览图(最大300px)
|
||||
@@ -87,7 +87,7 @@ type PostImage struct {
|
||||
Height int `json:"height" gorm:"default:0"`
|
||||
Size int64 `json:"size" gorm:"default:0"` // 文件大小(字节)
|
||||
MimeType string `json:"mime_type" gorm:"type:varchar(50)"`
|
||||
SortOrder int `json:"sort_order" gorm:"default:0"`
|
||||
SortOrder int `json:"sort_order" gorm:"default:0;index:idx_post_images_post_sort,priority:2"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user