From 2d676321a279b846a3cd1af8590860bfe07e6cd6 Mon Sep 17 00:00:00 2001 From: Fred K Date: Sat, 14 Feb 2026 04:43:38 -0500 Subject: [PATCH] feat(explorer): add a `notifyForBody` method to Lua environment This allows notifications to mark notifications as for a specific body like `Complex` and `Simple` criteria responses do by default. The Body ID given to this method is set to the Coalescing ID on the notification args. --- ObservatoryExplorer/CustomCriteriaManager.cs | 10 +++++++--- ObservatoryExplorer/Explorer.cs | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ObservatoryExplorer/CustomCriteriaManager.cs b/ObservatoryExplorer/CustomCriteriaManager.cs index 3fb46721..f680780f 100644 --- a/ObservatoryExplorer/CustomCriteriaManager.cs +++ b/ObservatoryExplorer/CustomCriteriaManager.cs @@ -18,11 +18,11 @@ internal class CustomCriteriaManager private Dictionary CriteriaFunctions; private Dictionary CriteriaWithErrors = new(); Action ErrorLogger; - private Action NotificationMethod; + private Action NotificationMethod; private uint ScanCount; private string eventTime = string.Empty; - public CustomCriteriaManager(Action errorLogger, Action notificationMethod) + public CustomCriteriaManager(Action errorLogger, Action notificationMethod) { ErrorLogger = errorLogger; CriteriaFunctions = new(); @@ -30,7 +30,10 @@ public CustomCriteriaManager(Action errorLogger, Action NotificationMethod(eventTime, title, detail, extendedDetail); + public void SendNotification(string title, string detail, string extendedDetail) + => NotificationMethod(eventTime, title, detail, extendedDetail, null); + public void SendNotificationForBody(string title, string detail, string extendedDetail, int bodyId) + => NotificationMethod(eventTime, title, detail, extendedDetail, bodyId); public void RefreshCriteria(string criteriaPath) { @@ -156,6 +159,7 @@ local count #region Convenience Functions LuaState.RegisterFunction("notify", this, typeof(CustomCriteriaManager).GetMethod("SendNotification")); + LuaState.RegisterFunction("notifyForBody", this, typeof(CustomCriteriaManager).GetMethod("SendNotificationForBody")); // Body type related functions and tests diff --git a/ObservatoryExplorer/Explorer.cs b/ObservatoryExplorer/Explorer.cs index 9696c6cd..54fe4009 100644 --- a/ObservatoryExplorer/Explorer.cs +++ b/ObservatoryExplorer/Explorer.cs @@ -383,7 +383,7 @@ private void SendNotification(Scan scanEvent, string detail, string extendedDeta ObservatoryCore.SendNotification(args); } - private void SendNotification(string title, string detail, string extendedDetail) + private void SendNotification(string title, string detail, string extendedDetail, int? coalescingId = null) { NotificationArgs args = new() { @@ -391,7 +391,7 @@ private void SendNotification(string title, string detail, string extendedDetail Detail = detail, Sender = ExplorerWorker.AboutInfo.ShortName, ExtendedDetails = extendedDetail, - CoalescingId = -1, + CoalescingId = coalescingId ?? -1, }; ObservatoryCore.SendNotification(args); @@ -410,9 +410,9 @@ private void AddGridItem(string eventTime, string title, string detail, string e ObservatoryCore.AddGridItem(ExplorerWorker, results); } - private void HandleCustomNotification(string eventTime, string title, string detail, string extendedDetail) + private void HandleCustomNotification(string eventTime, string title, string detail, string extendedDetail, int? coalescingId = null) { - SendNotification(title, detail, extendedDetail); + SendNotification(title, detail, extendedDetail, coalescingId); AddGridItem(eventTime, title, detail, extendedDetail); }