package models import ( "gorm.io/gorm" "time" "github.com/google/uuid" // Import uuid ) // UserSettings représente les paramètres utilisateur type UserSettings struct { ID uuid.UUID `gorm:"type:uuid;primaryKey"` UserID uuid.UUID `gorm:"not null;uniqueIndex;type:uuid"` // Change to uuid.UUID CreatedAt time.Time UpdatedAt time.Time // Notifications EmailNotifications bool `gorm:"default:true"` PushNotifications bool `gorm:"default:true"` BrowserNotifications bool `gorm:"default:true"` EmailOnFollow bool `gorm:"default:true"` EmailOnLike bool `gorm:"default:true"` EmailOnComment bool `gorm:"default:true"` EmailOnMessage bool `gorm:"default:true"` EmailOnMention bool `gorm:"default:true"` EmailMarketing bool `gorm:"default:false"` // Privacy AllowSearchIndexing bool `gorm:"default:true"` ShowActivity bool `gorm:"default:true"` // Content ExplicitContent bool `gorm:"default:false"` Autoplay bool `gorm:"default:true"` } // TableName définit le nom de la table pour GORM func (UserSettings) TableName() string { return "user_settings" } // UserProfile représente les préférences utilisateur (extended from User model) // Note: Les champs language, timezone, theme sont dans la table users pour l'instant // Cette structure est pour référence future si on veut une table séparée type UserProfile struct { ID uuid.UUID `gorm:"type:uuid;primaryKey"` UserID uuid.UUID `gorm:"not null;uniqueIndex;type:uuid"` // Change to uuid.UUID CreatedAt time.Time UpdatedAt time.Time // Preferences - stored in users table for now Language string `gorm:"default:'en'"` Timezone string `gorm:"default:'UTC'"` Theme string `gorm:"default:'auto'"` } // TableName définit le nom de la table pour GORM func (UserProfile) TableName() string { return "user_profiles" } // BeforeCreate hook GORM pour générer UUID si non défini func (m *UserSettings) BeforeCreate(tx *gorm.DB) error { if m.ID == uuid.Nil { m.ID = uuid.New() } return nil } // BeforeCreate hook GORM pour générer UUID si non défini func (m *UserProfile) BeforeCreate(tx *gorm.DB) error { if m.ID == uuid.Nil { m.ID = uuid.New() } return nil }