From befe962806b916c60cdaf1edc2c51416b35b95b9 Mon Sep 17 00:00:00 2001 From: Nishad Musthafa Date: Thu, 3 Jul 2025 13:57:15 -0700 Subject: [PATCH] Using a less complex mechanism to trunk matching by sending all trunks to MatchTrunkDetailed --- pkg/service/ioservice_sip.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/service/ioservice_sip.go b/pkg/service/ioservice_sip.go index b1c0cded9..0b11fe72a 100644 --- a/pkg/service/ioservice_sip.go +++ b/pkg/service/ioservice_sip.go @@ -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) if err != nil { return nil, err @@ -67,6 +67,13 @@ func (s *IOInfoService) SelectSIPInboundTrunk(ctx context.Context, called string 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. // 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) {