Implementation du mail

This commit is contained in:
2026-06-14 20:34:52 +02:00
parent 96b1741cd1
commit 53b1ad2063
8 changed files with 858 additions and 25 deletions
+50
View File
@@ -999,11 +999,18 @@ db.exec(`
{ name: 'remboursement', filename: 'icon_remboursement_seed.svg', description: 'Remboursement' },
{ name: 'retrait', filename: 'icon_retrait_seed.svg', description: 'Retrait de fonds' },
{ name: 'tax', filename: 'icon_tax_1780230337883.svg', description: 'Fiscalité / Tax' },
{ name: 'logo-app', filename: 'app-logo.svg', description: 'Logo principal de la plateforme' },
];
const ins = db.prepare(
'INSERT OR IGNORE INTO app_icons (name, filename, description) VALUES (?,?,?)'
);
for (const s of seeds) ins.run(s.name, s.filename, s.description);
} else {
// Garantit que logo-app existe même sur une DB déjà peuplée
db.prepare(`
INSERT OR IGNORE INTO app_icons (name, filename, description)
VALUES ('logo-app', 'app-logo.svg', 'Logo principal de la plateforme')
`).run();
}
}
@@ -1683,3 +1690,46 @@ db.exec(`
console.log(`[DB] ${toFix.length} date_cible aberrantes corrigées.`);
}
}
// ── Migration : table smtp_config ─────────────────────────────────────────
{
db.exec(`
CREATE TABLE IF NOT EXISTS smtp_config (
id INTEGER PRIMARY KEY CHECK (id = 1),
enabled INTEGER NOT NULL DEFAULT 0,
host TEXT,
port INTEGER NOT NULL DEFAULT 587,
secure INTEGER NOT NULL DEFAULT 0,
email TEXT,
username TEXT,
password TEXT,
allow_unauth INTEGER NOT NULL DEFAULT 0,
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
)
`);
// Seed row unique (id=1) si elle n'existe pas encore
const existing = db.prepare('SELECT id FROM smtp_config WHERE id = 1').get();
if (!existing) {
// Pré-remplir depuis les variables d'environnement si disponibles
db.prepare(`
INSERT INTO smtp_config (id, enabled, host, port, email, username, password)
VALUES (1, 0, ?, ?, ?, ?, ?)
`).run(
process.env.SMTP_HOST || null,
parseInt(process.env.SMTP_PORT || '587', 10),
process.env.SMTP_EMAIL || null,
process.env.SMTP_USERNAME || null,
process.env.SMTP_PASSWORD || null,
);
}
// Ajout des colonnes app_name et app_url si absentes
const smtpCols = db.prepare('PRAGMA table_info(smtp_config)').all().map(c => c.name);
if (!smtpCols.includes('app_name'))
db.exec(`ALTER TABLE smtp_config ADD COLUMN app_name TEXT DEFAULT 'Crowdlending'`);
if (!smtpCols.includes('app_url'))
db.exec(`ALTER TABLE smtp_config ADD COLUMN app_url TEXT DEFAULT ''`);
console.log('[DB] Table smtp_config OK');
}