File tree Expand file tree Collapse file tree
src/Infrastructure/BotSharp.OpenAPI/Controllers/Agent Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,20 +6,26 @@ namespace BotSharp.OpenAPI.Controllers;
66public partial class AgentController
77{
88 [ HttpGet ( "/rule/triggers/{agentId}" ) ]
9- public IEnumerable < AgentRuleViewModel > GetRuleTriggers ( string agentId )
9+ public ActionResult < IEnumerable < AgentRuleViewModel > > GetRuleTriggers ( string agentId )
1010 {
11- var triggers = _services . GetServices < IRuleTrigger > ( ) ;
12- if ( ! string . IsNullOrWhiteSpace ( agentId ) )
11+ if ( string . IsNullOrWhiteSpace ( agentId ) )
1312 {
14- triggers = triggers . Where ( x => x . AgentIds == null || x . AgentIds . Contains ( agentId , StringComparer . OrdinalIgnoreCase ) ) ;
13+ return BadRequest ( " agentId is required" ) ;
1514 }
16- return triggers . Select ( x => new AgentRuleViewModel
15+
16+ var triggers = _services . GetServices < IRuleTrigger > ( )
17+ . Where ( x =>
18+ {
19+ var agentIds = x . AgentIds ;
20+ return agentIds == null || agentIds . Contains ( agentId , StringComparer . OrdinalIgnoreCase ) ;
21+ } ) ;
22+ return Ok ( triggers . Select ( x => new AgentRuleViewModel
1723 {
1824 TriggerName = x . Name ,
1925 Channel = x . Channel ,
2026 Statement = x . Statement ,
2127 OutputArgs = x . OutputArgs
22- } ) . OrderBy ( x => x . TriggerName ) ;
28+ } ) . OrderBy ( x => x . TriggerName ) ) ;
2329 }
2430
2531 [ HttpGet ( "/rule/triggers" ) ]
You can’t perform that action at this time.
0 commit comments