feat(settings): seed clés d'intégration ntfy/email/IA en base (partiel #80)
- Seed idempotent des clés ntfy.baseUrl/ntfy.token, email.* (SMTP), ai.cpaiUrl, ai.ollamaUrl — catégorie 'integrations', valeurs initiales depuis env (migration douce env → DB) - Prérequis backend pour l'UI de configuration des intégrations (#79/#80)
This commit is contained in:
1 parent
7d6213696f
commit
a07a0cae52
1 file changed
+40
@@ -239,6 +239,46 @@ public partial class Program {
|
||||
}
|
||||
await groupDb.SaveChangesWithRetryAsync();
|
||||
|
||||
// Seed des paramètres d'intégration (idempotent) — source de vérité DB,
|
||||
// valeur initiale depuis env pour migration douce (ticket #80).
|
||||
var integrationDefaults = new Dictionary<string, string?>
|
||||
{
|
||||
["ntfy.baseUrl"] = Environment.GetEnvironmentVariable("NTFY__BASE_URL") ?? "https://ntfy.sh",
|
||||
["ntfy.token"] = Environment.GetEnvironmentVariable("NTFY__TOKEN"),
|
||||
["email.fromAddress"] = Environment.GetEnvironmentVariable("EMAIL__FROM_ADDRESS"),
|
||||
["email.fromName"] = Environment.GetEnvironmentVariable("EMAIL__FROM_NAME"),
|
||||
["email.smtpHost"] = Environment.GetEnvironmentVariable("EMAIL__SMTP_HOST"),
|
||||
["email.smtpPort"] = Environment.GetEnvironmentVariable("EMAIL__SMTP_PORT") ?? "587",
|
||||
["email.username"] = Environment.GetEnvironmentVariable("EMAIL__USERNAME"),
|
||||
["email.password"] = Environment.GetEnvironmentVariable("EMAIL__PASSWORD"),
|
||||
["email.useSsl"] = Environment.GetEnvironmentVariable("EMAIL__USE_SSL") ?? "true",
|
||||
["ai.cpaiUrl"] = Environment.GetEnvironmentVariable("CPAI_URL"),
|
||||
["ai.ollamaUrl"] = Environment.GetEnvironmentVariable("OLLAMA_URL"),
|
||||
};
|
||||
foreach (var (key, value) in integrationDefaults)
|
||||
{
|
||||
if (await groupDb.AppSettings.AnyAsync(s => s.Key == key))
|
||||
continue;
|
||||
groupDb.AppSettings.Add(new Heimdall.Domain.Entities.AppSetting(
|
||||
key, value ?? string.Empty, "integrations",
|
||||
key switch
|
||||
{
|
||||
"ntfy.baseUrl" => "Serveur ntfy (URL de base)",
|
||||
"ntfy.token" => "Token d'accès ntfy",
|
||||
"email.fromAddress" => "Adresse expéditrice des emails",
|
||||
"email.fromName" => "Nom expéditeur des emails",
|
||||
"email.smtpHost" => "Serveur SMTP",
|
||||
"email.smtpPort" => "Port SMTP",
|
||||
"email.username" => "Utilisateur SMTP",
|
||||
"email.password" => "Mot de passe SMTP",
|
||||
"email.useSsl" => "Utiliser SSL/TLS pour SMTP",
|
||||
"ai.cpaiUrl" => "URL CodeProject.AI",
|
||||
"ai.ollamaUrl" => "URL Ollama",
|
||||
_ => key
|
||||
}));
|
||||
}
|
||||
await groupDb.SaveChangesWithRetryAsync();
|
||||
|
||||
// Seed demo admin + demo site when explicitly enabled (dev & E2E hosts)
|
||||
if (configuration.GetValue<bool>("Seed:DemoOnStartup", false))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user