Using a less complex mechanism to trunk matching by sending all trunks to MatchTrunkDetailed

This commit is contained in:
Nishad Musthafa
2025-07-03 13:57:15 -07:00
parent 6f89ead3dd
commit befe962806

View File

@@ -44,7 +44,7 @@ func (s *IOInfoService) matchSIPTrunk(ctx context.Context, trunkID string, call
} }
} }
} }
it := s.SelectSIPInboundTrunk(ctx, call.To.User) it := s.ListAllSIPInboundTrunks(ctx, call.To.User)
result, err := sip.MatchTrunkDetailed(it, call) result, err := sip.MatchTrunkDetailed(it, call)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -67,6 +67,13 @@ func (s *IOInfoService) SelectSIPInboundTrunk(ctx context.Context, called string
return iters.PagesAsIter(ctx, it) return iters.PagesAsIter(ctx, it)
} }
func (s *IOInfoService) ListAllSIPInboundTrunks(ctx context.Context, called string) iters.Iter[*livekit.SIPInboundTrunkInfo] {
it := livekit.ListPageIter(s.ss.ListSIPInboundTrunk, &livekit.ListSIPInboundTrunkRequest{
Numbers: nil,
})
return iters.PagesAsIter(ctx, it)
}
// matchSIPDispatchRule finds the best dispatch rule matching the request parameters. Returns an error if no rule matched. // matchSIPDispatchRule finds the best dispatch rule matching the request parameters. Returns an error if no rule matched.
// Trunk parameter can be nil, in which case only wildcard dispatch rules will be effective (ones without Trunk IDs). // Trunk parameter can be nil, in which case only wildcard dispatch rules will be effective (ones without Trunk IDs).
func (s *IOInfoService) matchSIPDispatchRule(ctx context.Context, trunk *livekit.SIPInboundTrunkInfo, req *rpc.EvaluateSIPDispatchRulesRequest) (*livekit.SIPDispatchRuleInfo, error) { func (s *IOInfoService) matchSIPDispatchRule(ctx context.Context, trunk *livekit.SIPInboundTrunkInfo, req *rpc.EvaluateSIPDispatchRulesRequest) (*livekit.SIPDispatchRuleInfo, error) {