("Ntfy:BaseUrl")
?? Environment.GetEnvironmentVariable("NTFY__BASE_URL")
?? "http://ntfy:80";
diff --git a/src/Heimdall.Web/Components/Pages/Profile.razor b/src/Heimdall.Web/Components/Pages/Profile.razor
index 82556b7..7acf69f 100644
--- a/src/Heimdall.Web/Components/Pages/Profile.razor
+++ b/src/Heimdall.Web/Components/Pages/Profile.razor
@@ -178,10 +178,15 @@ else if (_profile is not null)
}
-
+
Les notifications push utilisent ntfy (serveur auto-hébergé).
- Votre topic personnel est heimdall_@_profile.Id.
- Installez l'app ntfy et abonnez-vous à ce topic pour recevoir les notifications.
+ Installez l'app ntfy et abonnez-vous au topic ci-dessous pour recevoir les notifications.
+
+
+ Votre topic : @($"heimdall_{_profile?.Id}")
+
+
+ Ce topic est unique par utilisateur. Vous pouvez aussi utiliser un topic de site si configuré.
@@ -207,6 +212,19 @@ else if (_profile is not null)
@if (_savingNotif) { }
Enregistrer
+
+
+
+ @(_testingNtfy ? "Test en cours…" : "Tester ntfy")
+
+
+ @if (_ntfyTestResult is not null)
+ {
+
+ @_ntfyTestResult.Message
+
+ }
}
@@ -470,6 +488,8 @@ else if (_profile is not null)
private bool _weeklyDigest;
private bool _savingNotif;
private string _notifError = "";
+ private bool _testingNtfy;
+ private TestActionResult? _ntfyTestResult;
private async Task LoadNotificationConfig()
{
@@ -522,4 +542,24 @@ else if (_profile is not null)
}
finally { _savingNotif = false; }
}
+
+ private async Task TestNtfyForUserAsync()
+ {
+ _testingNtfy = true;
+ _ntfyTestResult = null;
+ try
+ {
+ var topic = _profile is not null ? $"heimdall_{_profile.Id}" : null;
+ _ntfyTestResult = await Api.TestNtfyAsync(topic)
+ ?? new TestActionResult(false, "Test impossible (API indisponible).");
+ }
+ catch (Exception ex)
+ {
+ _ntfyTestResult = new TestActionResult(false, $"Test impossible : {ex.Message}");
+ }
+ finally
+ {
+ _testingNtfy = false;
+ }
+ }
}
diff --git a/src/Heimdall.Web/Controllers/SettingsController.cs b/src/Heimdall.Web/Controllers/SettingsController.cs
index 0e42025..f2d1a05 100644
--- a/src/Heimdall.Web/Controllers/SettingsController.cs
+++ b/src/Heimdall.Web/Controllers/SettingsController.cs
@@ -293,7 +293,7 @@ public class SettingsController : ControllerBase
{
var topic = string.IsNullOrWhiteSpace(request?.Topic) ? "heimdall-test" : request.Topic;
var ok = await ntfyService.SendTestAsync(topic, "Heimdall — test de configuration",
- "✅ Notification ntfy reçue : le serveur est joignable et le token est accepté.", ct);
+ "✅ Notification ntfy reçue : le serveur est joignable et le token est accepté.", ct: ct);
return Ok(new
{
success = ok,
diff --git a/src/Heimdall.Web/Services/HeimdallApiClient.cs b/src/Heimdall.Web/Services/HeimdallApiClient.cs
index c225664..273ada1 100644
--- a/src/Heimdall.Web/Services/HeimdallApiClient.cs
+++ b/src/Heimdall.Web/Services/HeimdallApiClient.cs
@@ -618,10 +618,11 @@ public class HeimdallApiClient
}
/// Send a test ntfy notification (POST /api/settings/ntfy/test).
- public async Task TestNtfyAsync()
+ public async Task TestNtfyAsync(string? topic = null)
{
var client = CreateClient();
- var response = await client.PostAsync("api/settings/ntfy/test", null);
+ var payload = new { topic };
+ var response = await client.PostAsJsonAsync("api/settings/ntfy/test", payload, Json);
if (!response.IsSuccessStatusCode)
return null;
return await response.Content.ReadFromJsonAsync();