34 lines
1.4 KiB
Go
34 lines
1.4 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// CommentConfig holds the singleton (id=1) global comment policy.
|
|
type CommentConfig struct {
|
|
ID uint `gorm:"primarykey" json:"id"`
|
|
Enabled bool `gorm:"default:true" json:"enabled"` // master switch for the comment system
|
|
AllowGuest bool `gorm:"default:true" json:"allow_guest"` // whether anonymous (non-logged-in) comments are allowed
|
|
GuestRequireApproval bool `gorm:"default:false" json:"guest_require_approval"` // hold guest comments in the moderation queue
|
|
// SECURITY_TODO #15: Gravatar reveals MD5(email) via reverse lookup;
|
|
// off by default on new deployments (admins can re-enable explicitly).
|
|
UseGravatar bool `gorm:"default:false" json:"use_gravatar"` // when false, avatars render as a text-initial placeholder
|
|
UpdatedBy uint `gorm:"index" json:"updated_by"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// TableName overrides the default GORM table name.
|
|
func (CommentConfig) TableName() string {
|
|
return "comment_configs"
|
|
}
|
|
|
|
// defaultCommentConfig returns the in-memory fallback used before the DB row is
|
|
// seeded, matching the seed defaults.
|
|
func defaultCommentConfig() *CommentConfig {
|
|
return &CommentConfig{
|
|
ID: 1,
|
|
Enabled: true,
|
|
AllowGuest: true,
|
|
GuestRequireApproval: false,
|
|
UseGravatar: false,
|
|
}
|
|
}
|