chore: update
ci-api / test (push) Successful in 22m17s
ci-web / test (push) Successful in 13m44s

This commit is contained in:
Xor290
2026-08-02 18:34:59 +02:00
parent 6992e505ae
commit c5ee5636ef
34 changed files with 2660 additions and 498 deletions
@@ -19,6 +19,8 @@ type Store interface {
UpdatePassword(id, passwordHahs string) (auth.User, error)
GetTelegram(id string) (auth.User, error)
SetTelegram(id, telegram string) (auth.User, error)
GetAlertSettings(id string) (auth.User, error)
SetAlertSettings(id string, discordWebhookURL, telegramBotToken, telegramChatID string) (auth.User, error)
}
func (s *GormStore) UpdateUsername(id, newUsername string) (auth.User, error) {
@@ -71,3 +73,36 @@ func (s *GormStore) SetTelegram(id, telegram string) (auth.User, error) {
}
return user, nil
}
func (s *GormStore) GetAlertSettings(id string) (auth.User, error) {
var user auth.User
if err := s.db.First(&user, "id = ?", id).Error; err != nil {
return auth.User{}, err
}
return user, nil
}
// SetAlertSettings enregistre les réglages d'alerte de cet admin. Une chaîne
// vide efface le champ correspondant (désactive ce canal pour cet admin).
func (s *GormStore) SetAlertSettings(id string, discordWebhookURL, telegramBotToken, telegramChatID string) (auth.User, error) {
updates := map[string]interface{}{
"alert_discord_webhook_url": nullIfEmpty(discordWebhookURL),
"alert_telegram_bot_token": nullIfEmpty(telegramBotToken),
"alert_telegram_chat_id": nullIfEmpty(telegramChatID),
}
if err := s.db.Model(&auth.User{}).Where("id = ?", id).Updates(updates).Error; err != nil {
return auth.User{}, err
}
var user auth.User
if err := s.db.First(&user, "id = ?", id).Error; err != nil {
return auth.User{}, err
}
return user, nil
}
func nullIfEmpty(s string) *string {
if s == "" {
return nil
}
return &s
}