Fix the issue of UserIdentity loss

This commit is contained in:
nick.yi 2025-04-25 16:01:52 +08:00
parent 45341eb02e
commit 0302ccc9c5
2 changed files with 18 additions and 1 deletions

View file

@ -0,0 +1,13 @@
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);
}
}

View file

@ -115,7 +115,11 @@ public class CrontabService : ICrontabService, ITaskFeeder
public async Task ScheduledTimeArrived(CrontabItem item)
{
_logger.LogDebug($"ScheduledTimeArrived {item}");
HookEmitter.Emit<ICrontabAuthenticationHook>(_services, hook =>
{
hook.SetUserIdentity(item);
});
await HookEmitter.Emit<ICrontabHook>(_services, async hook =>
{
if (hook.Triggers == null || hook.Triggers.Contains(item.Title))