diff --git a/src/Infrastructure/BotSharp.Core.Crontab/Abstraction/ICrontabAuthenticationHook.cs b/src/Infrastructure/BotSharp.Core.Crontab/Abstraction/ICrontabAuthenticationHook.cs deleted file mode 100644 index 031c67fb..00000000 --- a/src/Infrastructure/BotSharp.Core.Crontab/Abstraction/ICrontabAuthenticationHook.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace BotSharp.Core.Crontab.Abstraction -{ - public interface ICrontabAuthenticationHook - { - void SetUserIdentity(CrontabItem item); - } -} diff --git a/src/Infrastructure/BotSharp.Core.Crontab/Abstraction/ICrontabHook.cs b/src/Infrastructure/BotSharp.Core.Crontab/Abstraction/ICrontabHook.cs index 45f997e0..36ca9358 100644 --- a/src/Infrastructure/BotSharp.Core.Crontab/Abstraction/ICrontabHook.cs +++ b/src/Infrastructure/BotSharp.Core.Crontab/Abstraction/ICrontabHook.cs @@ -1,16 +1,20 @@ namespace BotSharp.Core.Crontab.Abstraction; -public interface ICrontabHook +public abstract class ICrontabHook { - string[]? Triggers + public string[]? Triggers => null; - Task OnCronTriggered(CrontabItem item) + public virtual void OnAuthenticate(CrontabItem item) + { + } + + public Task OnCronTriggered(CrontabItem item) => Task.CompletedTask; - Task OnTaskExecuting(CrontabItem item) + public Task OnTaskExecuting(CrontabItem item) => Task.CompletedTask; - Task OnTaskExecuted(CrontabItem item) + public Task OnTaskExecuted(CrontabItem item) => Task.CompletedTask; } diff --git a/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabService.cs b/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabService.cs index 213dbbaa..7ff105c9 100644 --- a/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabService.cs +++ b/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabService.cs @@ -115,15 +115,12 @@ public class CrontabService : ICrontabService, ITaskFeeder public async Task ScheduledTimeArrived(CrontabItem item) { _logger.LogDebug($"ScheduledTimeArrived {item}"); - HookEmitter.Emit(_services, hook => - { - hook.SetUserIdentity(item); - }); await HookEmitter.Emit(_services, async hook => { if (hook.Triggers == null || hook.Triggers.Contains(item.Title)) { + hook.OnAuthenticate(item); await hook.OnTaskExecuting(item); await hook.OnCronTriggered(item); await hook.OnTaskExecuted(item);