diff --git a/setup.html b/setup.html
index f1c869b..4ff0a1e 100644
--- a/setup.html
+++ b/setup.html
@@ -3233,15 +3233,24 @@
return h;
}
+ const setupNotifVerifiedSigs = {};
+
+ function getNotifChannelSignature(ch, cfg) {
+ const c = (cfg || getNotificationFormPayload())[ch];
+ if (!c) return '';
+ return JSON.stringify(c);
+ }
+
async function testSetupNotification(channel) {
const detailsBox = $('setupNotifTestDetails');
if (detailsBox) {
detailsBox.innerHTML = `
⏳ ${t('notif_testing_progress', 'Envoi de la notification de test en cours…')}
`;
}
+ const testedConfig = getNotificationFormPayload();
try {
const payload = {
channel: channel,
- config: getNotificationFormPayload()
+ config: testedConfig
};
const res = await fetch(API_URL + '/api/notifications/test', {
method: 'POST',
@@ -3269,17 +3278,30 @@
for (const [ch, info] of Object.entries(results)) {
const chName = labels[ch] || ch;
if (info.ok) {
+ if (ch !== 'general') {
+ setupNotifVerifiedSigs[ch] = getNotifChannelSignature(ch, testedConfig);
+ }
html += `✅ ${chName} : ${info.message || 'Succès'}
`;
} else {
+ if (ch !== 'general') {
+ delete setupNotifVerifiedSigs[ch];
+ }
html += `❌ ${chName} : ${info.error || 'Échec'}
`;
}
}
html += '';
if (detailsBox) detailsBox.innerHTML = html;
} catch (e) {
+ if (channel && channel !== 'all') {
+ delete setupNotifVerifiedSigs[channel];
+ } else {
+ Object.keys(setupNotifVerifiedSigs).forEach(k => delete setupNotifVerifiedSigs[k]);
+ }
if (detailsBox) {
detailsBox.innerHTML = `❌ ${t('notif_test_err', 'Erreur lors du test : ')} ${e.message}
`;
}
+ } finally {
+ updateStep4ContinueState();
}
}
@@ -3573,7 +3595,7 @@
{ id: 'notifWebhookEnabled', name: 'Webhook' }
];
let activeChannels = [];
- if (notifSt.anyConfigured) {
+ if (notifSt.ready) {
channels.forEach(c => {
if ($(c.id) && $(c.id).checked) activeChannels.push(c.name);
});
@@ -3625,7 +3647,7 @@
if (stepNum < 1 || stepNum > 6) return;
if (currentStep === 4 && stepNum > 4) {
const st = getStep4NotificationStatus();
- if (st.anyChecked && !st.anyConfigured) {
+ if (st.anyChecked && !st.ready) {
updateStep4ContinueState();
selectSetupNotifSubTab('services');
return;
@@ -3733,19 +3755,26 @@
function getStep4NotificationStatus() {
const p = getNotificationFormPayload();
const checks = [
- { en: p.email.enabled, ok: !!(p.email.smtp_host && p.email.to_addr) },
- { en: p.gotify.enabled, ok: !!(p.gotify.server_url && p.gotify.token) },
- { en: p.discord.enabled, ok: !!p.discord.webhook_url },
- { en: p.ntfy.enabled, ok: !!(p.ntfy.server_url && p.ntfy.topic) },
- { en: p.pushbullet.enabled, ok: !!p.pushbullet.api_token },
- { en: p.pushover.enabled, ok: !!(p.pushover.user_key && p.pushover.api_token) },
- { en: p.slack.enabled, ok: !!p.slack.webhook_url },
- { en: p.telegram.enabled, ok: !!(p.telegram.bot_token && p.telegram.chat_id) },
- { en: p.webhook.enabled, ok: !!p.webhook.url }
+ { key: 'email', en: p.email.enabled, ok: !!(p.email.smtp_host && p.email.to_addr) },
+ { key: 'gotify', en: p.gotify.enabled, ok: !!(p.gotify.server_url && p.gotify.token) },
+ { key: 'discord', en: p.discord.enabled, ok: !!p.discord.webhook_url },
+ { key: 'ntfy', en: p.ntfy.enabled, ok: !!(p.ntfy.server_url && p.ntfy.topic) },
+ { key: 'pushbullet', en: p.pushbullet.enabled, ok: !!p.pushbullet.api_token },
+ { key: 'pushover', en: p.pushover.enabled, ok: !!(p.pushover.user_key && p.pushover.api_token) },
+ { key: 'slack', en: p.slack.enabled, ok: !!p.slack.webhook_url },
+ { key: 'telegram', en: p.telegram.enabled, ok: !!(p.telegram.bot_token && p.telegram.chat_id) },
+ { key: 'webhook', en: p.webhook.enabled, ok: !!p.webhook.url }
];
+ const enabledList = checks.filter(c => c.en);
+ const anyChecked = enabledList.length > 0;
+ const allEnabledConfigured = anyChecked && enabledList.every(c => c.ok);
+ const allEnabledVerified = allEnabledConfigured && enabledList.every(c => setupNotifVerifiedSigs[c.key] === getNotifChannelSignature(c.key, p));
return {
- anyChecked: checks.some(c => c.en),
- anyConfigured: checks.some(c => c.en && c.ok)
+ anyChecked,
+ anyConfigured: allEnabledConfigured,
+ allEnabledConfigured,
+ allEnabledVerified,
+ ready: allEnabledVerified
};
}
@@ -3755,19 +3784,26 @@
const st = getStep4NotificationStatus();
const isEn = currentLanguage.startsWith('en');
- if (!st.anyConfigured) {
+ if (!st.ready) {
if (btn) {
btn.disabled = true;
btn.style.opacity = '0.5';
btn.style.cursor = 'not-allowed';
}
- const msg = st.anyChecked
- ? (isEn
- ? '⚠️ Please fill in the required fields for the enabled notification service (URL, token, recipient...) to continue, or click "Skip".'
- : '⚠️ Veuillez compléter les champs obligatoires du service de notification activé (URL, jeton, destinataire...) pour continuer, ou cliquez sur « Ignorer ».')
- : (isEn
- ? '⚠️ Please enable and configure at least one notification service to continue, or click "Skip".'
- : '⚠️ Veuillez activer et configurer au moins un service de notification pour continuer, ou cliquez sur « Ignorer ».');
+ let msg;
+ if (!st.anyChecked) {
+ msg = isEn
+ ? '⚠️ Please enable, configure, and test at least one notification service to continue, or click "Skip".'
+ : '⚠️ Veuillez activer, configurer et tester au moins un service de notification pour continuer, ou cliquez sur « Ignorer ».';
+ } else if (!st.allEnabledConfigured) {
+ msg = isEn
+ ? '⚠️ Please fill in the required fields for each enabled notification service (URL, token, recipient...) to continue, or click "Skip".'
+ : '⚠️ Veuillez compléter les champs obligatoires de chaque service de notification activé (URL, jeton, destinataire...) pour continuer, ou cliquez sur « Ignorer ».';
+ } else {
+ msg = isEn
+ ? '🧪 Please click "Test" and make sure the test succeeds before continuing (or click "Skip").'
+ : '🧪 Veuillez lancer un test réussi sur chaque service activé avant de pouvoir continuer (ou cliquez sur « Ignorer »).';
+ }
showError(errEl, msg);
} else {
if (btn) {
@@ -3784,6 +3820,7 @@
const chk = $('notif' + cap + 'Enabled');
if (chk) chk.checked = false;
});
+ Object.keys(setupNotifVerifiedSigs).forEach(k => delete setupNotifVerifiedSigs[k]);
toggleNotifFields();
if ($('step4Error')) $('step4Error').style.display = 'none';
goToStep(5);
@@ -3792,7 +3829,7 @@
function validateStep4() {
updateStep4ContinueState();
const st = getStep4NotificationStatus();
- if (!st.anyConfigured) {
+ if (!st.ready) {
selectSetupNotifSubTab('services');
return;
}
@@ -4033,7 +4070,7 @@
if (!password || password !== confirmation) { goToStep(2); return validateStep2(); }
if (!adminUser || !adminPass) { goToStep(3); return validateStep3(); }
const notifSt = getStep4NotificationStatus();
- if (notifSt.anyChecked && !notifSt.anyConfigured) { goToStep(4); return validateStep4(); }
+ if (notifSt.anyChecked && !notifSt.ready) { goToStep(4); return validateStep4(); }
isConfiguring = true;
btn.disabled = true;
@@ -4122,8 +4159,8 @@
}
}
- // E. Enregistrement des notifications (si au moins un service configuré)
- if (notifSt.anyConfigured) {
+ // E. Enregistrement des notifications (si au moins un service configuré et testé)
+ if (notifSt.ready) {
msg.textContent = isEn ? '4/5 Saving notification channels & alert events…' : '4/5 Enregistrement des alertes et notifications…';
if (progBar) progBar.style.width = '80%';
try {