Skip to content

Commit 80f68c8

Browse files
author
aden.chen
committed
Filter cron jobs by TriggerType before processing
Only cron jobs with a TriggerType of BackgroundWatcher are now processed. Introduced allowedCrons to hold the filtered list and updated iteration logic to use this list.
1 parent 0abd1c8 commit 80f68c8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabEventSubscription.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
2929
var subscriber = scope.ServiceProvider.GetRequiredService<IEventSubscriber>();
3030
var cron = scope.ServiceProvider.GetRequiredService<ICrontabService>();
3131
var crons = await cron.GetCrontable();
32-
foreach (var item in crons)
32+
var allowedCrons = crons.Where(cron => cron.TriggerType == CronTabItemTriggerType.BackgroundWatcher).ToList();
33+
foreach (var item in allowedCrons)
3334
{
3435
_ = Task.Run(async () =>
3536
{

0 commit comments

Comments
 (0)