File tree Expand file tree Collapse file tree
BotSharp.Abstraction/Routing/Models Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,6 +37,21 @@ public override string ToString()
3737
3838 public RoutingRule ( )
3939 {
40-
4140 }
41+
42+ /// <summary>
43+ /// Returns a defensive copy so hook mutations do not affect cached/shared instances.
44+ /// </summary>
45+ public RoutingRule Clone ( ) => new RoutingRule
46+ {
47+ AgentId = AgentId ,
48+ AgentName = AgentName ,
49+ Type = Type ,
50+ Field = Field ,
51+ Description = Description ,
52+ FieldType = FieldType ,
53+ Required = Required ,
54+ RedirectTo = RedirectTo ,
55+ RedirectToAgentName = RedirectToAgentName
56+ } ;
4257}
Original file line number Diff line number Diff line change @@ -149,6 +149,7 @@ public async Task<RoutingRule[]> GetRulesByAgentName(string name)
149149 var records = await GetRoutingRecords ( ) ;
150150 var rules = records
151151 . Where ( x => x . AgentName . ToLower ( ) == name . ToLower ( ) )
152+ . Select ( r => r . Clone ( ) )
152153 . ToList ( ) ;
153154 if ( rules . Count > 0 )
154155 {
@@ -163,6 +164,7 @@ public async Task<RoutingRule[]> GetRulesByAgentId(string id)
163164 var records = await GetRoutingRecords ( ) ;
164165 var rules = records
165166 . Where ( x => x . AgentId == id )
167+ . Select ( r => r . Clone ( ) )
166168 . ToList ( ) ;
167169 if ( rules . Count > 0 )
168170 {
You can’t perform that action at this time.
0 commit comments