feat(notifications): add user-configurable ntfy to
This commit is contained in:
1 parent
2ac2789728
commit
7a89a97bf3
15 files changed
+2310
-22
No files matched your search
@@ -141,10 +141,20 @@ public class NotificationService : INotificationService
|
||||
|
||||
/// <summary>
|
||||
/// Résout le topic ntfy cible d'une notification (ticket #105) :
|
||||
/// topic du site si défini, sinon topic personnel <c>heimdall_{userId}</c>.
|
||||
/// topic configuré par l'utilisateur (NtfyTopic) > topic du site > défaut heimdall_{userId}.
|
||||
/// </summary>
|
||||
private async Task<string> ResolveNtfyTopicAsync(Notification notification, Guid userId, CancellationToken ct)
|
||||
{
|
||||
// 1. User-configured topic (from profile settings)
|
||||
var userConfig = await _context.UserNotificationConfigs
|
||||
.AsNoTracking()
|
||||
.Where(c => c.UserId == userId)
|
||||
.Select(c => c.NtfyTopic)
|
||||
.FirstOrDefaultAsync(ct);
|
||||
if (!string.IsNullOrWhiteSpace(userConfig))
|
||||
return userConfig;
|
||||
|
||||
// 2. Site-level topic
|
||||
if (notification.SiteId is { } siteId)
|
||||
{
|
||||
var siteTopic = await _context.Sites
|
||||
@@ -156,6 +166,7 @@ public class NotificationService : INotificationService
|
||||
return siteTopic;
|
||||
}
|
||||
|
||||
// 3. Default
|
||||
return $"heimdall_{userId}";
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user