File tree Expand file tree Collapse file tree
src/Infrastructure/BotSharp.Core.Crontab/Services Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -130,10 +130,15 @@ await HookEmitter.Emit<ICrontabHook>(_services, async hook =>
130130 } , item . AgentId ) ;
131131 }
132132
133+ /// <summary>
134+ /// Returns whether the trigger is treated as enabled for this schedule: <c>true</c> unless a rule with the
135+ /// same trigger name exists and is explicitly disabled (opt-out). Missing rules do not block.
136+ /// </summary>
133137 private async Task < bool > HasEnabledTriggerRule ( CrontabItem item )
134138 {
135139 var agentService = _services . GetRequiredService < IAgentService > ( ) ;
136- if ( string . IsNullOrEmpty ( item . AgentId ) ) return true ;
140+ // No agent context: do not gate (legacy / callers without AgentId).
141+ if ( string . IsNullOrEmpty ( item . AgentId ) ) return true ;
137142
138143 var agent = await agentService . GetAgent ( item . AgentId ) ;
139144 if ( agent == null )
@@ -142,6 +147,7 @@ private async Task<bool> HasEnabledTriggerRule(CrontabItem item)
142147 return false ;
143148 }
144149
145- return agent . Rules . Any ( r => r . TriggerName == item . Title && ! r . Disabled ) ;
150+ // Opt-out only: block when a matching trigger rule exists and Disabled is true.
151+ return ! agent . Rules . Any ( r => r . TriggerName == item . Title && r . Disabled ) ;
146152 }
147153}
You can’t perform that action at this time.
0 commit comments