From db387c66139d014fca6b89eea35c760e461db0e0 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Wed, 18 Mar 2026 09:13:10 -0400 Subject: [PATCH] fix: include recipients in artifact deployment and load shared scripts on startup NotificationRepository.GetAllNotificationListsAsync() was missing .Include(Recipients), causing artifact deployments to push empty recipient lists to sites. Also load shared scripts from SQLite on DeploymentManager startup so they're available before Instance Actors compile their scripts. --- .../Repositories/NotificationRepository.cs | 2 +- .../Actors/DeploymentManagerActor.cs | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/ScadaLink.ConfigurationDatabase/Repositories/NotificationRepository.cs b/src/ScadaLink.ConfigurationDatabase/Repositories/NotificationRepository.cs index 55066da..30a47d8 100644 --- a/src/ScadaLink.ConfigurationDatabase/Repositories/NotificationRepository.cs +++ b/src/ScadaLink.ConfigurationDatabase/Repositories/NotificationRepository.cs @@ -17,7 +17,7 @@ public class NotificationRepository : INotificationRepository => await _context.Set().FindAsync(new object[] { id }, cancellationToken); public async Task> GetAllNotificationListsAsync(CancellationToken cancellationToken = default) - => await _context.Set().ToListAsync(cancellationToken); + => await _context.Set().Include(n => n.Recipients).ToListAsync(cancellationToken); public async Task GetListByNameAsync(string name, CancellationToken cancellationToken = default) => await _context.Set().FirstOrDefaultAsync(l => l.Name == name, cancellationToken); diff --git a/src/ScadaLink.SiteRuntime/Actors/DeploymentManagerActor.cs b/src/ScadaLink.SiteRuntime/Actors/DeploymentManagerActor.cs index 9de0b17..d8513ac 100644 --- a/src/ScadaLink.SiteRuntime/Actors/DeploymentManagerActor.cs +++ b/src/ScadaLink.SiteRuntime/Actors/DeploymentManagerActor.cs @@ -147,6 +147,9 @@ public class DeploymentManagerActor : ReceiveActor, IWithTimers return; } + // Load and compile shared scripts from SQLite before creating Instance Actors + LoadSharedScriptsFromStorage(); + var enabledConfigs = msg.Configs.Where(c => c.IsEnabled).ToList(); _totalDeployedCount = msg.Configs.Count; _logger.LogInformation( @@ -449,6 +452,29 @@ public class DeploymentManagerActor : ReceiveActor, IWithTimers } } + // ── Shared Script Loading ── + + private void LoadSharedScriptsFromStorage() + { + try + { + var scripts = _storage.GetAllSharedScriptsAsync().GetAwaiter().GetResult(); + var compiled = 0; + foreach (var script in scripts) + { + if (_sharedScriptLibrary.CompileAndRegister(script.Name, script.Code)) + compiled++; + } + _logger.LogInformation( + "Loaded {Compiled}/{Total} shared scripts from SQLite", + compiled, scripts.Count); + } + catch (Exception ex) + { + _logger.LogError(ex, "Failed to load shared scripts from SQLite"); + } + } + // ── Debug View routing ── private void RouteDebugViewSubscribe(SubscribeDebugViewRequest request)