From 4325bfe2d9e6e174ffa2229d195cb20780a0ca2e Mon Sep 17 00:00:00 2001 From: Haiping Date: Thu, 14 Aug 2025 21:24:26 +0000 Subject: [PATCH] publish cron event only if settings.EventSubscriber.Enabled --- .../BotSharp.Core.Crontab/Services/CrontabWatcher.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabWatcher.cs b/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabWatcher.cs index 1546cb7c..f6ce7a26 100644 --- a/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabWatcher.cs +++ b/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabWatcher.cs @@ -45,6 +45,7 @@ public class CrontabWatcher : BackgroundService { var cron = services.GetRequiredService(); var crons = await cron.GetCrontable(); + var settings = services.GetRequiredService(); var publisher = services.GetService(); foreach (var item in crons) @@ -87,7 +88,7 @@ public class CrontabWatcher : BackgroundService { _logger.LogInformation($"The current time matches the cron expression {item}"); - if (publisher != null) + if (publisher != null && settings.EventSubscriber.Enabled) { await publisher.PublishAsync($"Crontab:{item.Title}", item.Cron); }