Stubs for SIP update API. (#3533)
This commit is contained in:
+70
-12
@@ -86,6 +86,9 @@ func (s *SIPService) CreateSIPTrunk(ctx context.Context, req *livekit.CreateSIPT
|
||||
Name: req.Name,
|
||||
Metadata: req.Metadata,
|
||||
}
|
||||
if err := info.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Validate all trunks including the new one first.
|
||||
it, err := ListSIPInboundTrunk(ctx, s.store, &livekit.ListSIPInboundTrunkRequest{}, info.AsInbound())
|
||||
@@ -120,7 +123,7 @@ func (s *SIPService) CreateSIPInboundTrunk(ctx context.Context, req *livekit.Cre
|
||||
if info.SipTrunkId != "" {
|
||||
return nil, twirp.NewError(twirp.InvalidArgument, "trunk ID must be empty")
|
||||
}
|
||||
AppendLogFields(ctx, "trunk", logger.Proto(req.Trunk))
|
||||
AppendLogFields(ctx, "trunk", logger.Proto(info))
|
||||
|
||||
// Keep ID empty still, so that validation can print "<new>" instead of a non-existent ID in the error.
|
||||
|
||||
@@ -159,7 +162,7 @@ func (s *SIPService) CreateSIPOutboundTrunk(ctx context.Context, req *livekit.Cr
|
||||
if info.SipTrunkId != "" {
|
||||
return nil, twirp.NewError(twirp.InvalidArgument, "trunk ID must be empty")
|
||||
}
|
||||
AppendLogFields(ctx, "trunk", logger.Proto(req.Trunk))
|
||||
AppendLogFields(ctx, "trunk", logger.Proto(info))
|
||||
|
||||
// No additional validation needed for outbound.
|
||||
info.SipTrunkId = guid.New(utils.SIPTrunkPrefix)
|
||||
@@ -169,6 +172,44 @@ func (s *SIPService) CreateSIPOutboundTrunk(ctx context.Context, req *livekit.Cr
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func (s *SIPService) UpdateSIPInboundTrunk(ctx context.Context, req *livekit.UpdateSIPInboundTrunkRequest) (*livekit.SIPInboundTrunkInfo, error) {
|
||||
if err := EnsureSIPAdminPermission(ctx); err != nil {
|
||||
return nil, twirpAuthError(err)
|
||||
}
|
||||
if s.store == nil {
|
||||
return nil, ErrSIPNotConnected
|
||||
}
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
AppendLogFields(ctx,
|
||||
"request", logger.Proto(req),
|
||||
"trunkID", req.SipTrunkId,
|
||||
)
|
||||
|
||||
return nil, twirp.NewError(twirp.Unimplemented, "not implemented")
|
||||
}
|
||||
|
||||
func (s *SIPService) UpdateSIPOutboundTrunk(ctx context.Context, req *livekit.UpdateSIPOutboundTrunkRequest) (*livekit.SIPOutboundTrunkInfo, error) {
|
||||
if err := EnsureSIPAdminPermission(ctx); err != nil {
|
||||
return nil, twirpAuthError(err)
|
||||
}
|
||||
if s.store == nil {
|
||||
return nil, ErrSIPNotConnected
|
||||
}
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
AppendLogFields(ctx,
|
||||
"request", logger.Proto(req),
|
||||
"trunkID", req.SipTrunkId,
|
||||
)
|
||||
|
||||
return nil, twirp.NewError(twirp.Unimplemented, "not implemented")
|
||||
}
|
||||
|
||||
func (s *SIPService) GetSIPInboundTrunk(ctx context.Context, req *livekit.GetSIPInboundTrunkRequest) (*livekit.GetSIPInboundTrunkResponse, error) {
|
||||
if err := EnsureSIPAdminPermission(ctx); err != nil {
|
||||
return nil, twirpAuthError(err)
|
||||
@@ -326,16 +367,8 @@ func (s *SIPService) CreateSIPDispatchRule(ctx context.Context, req *livekit.Cre
|
||||
"trunkID", req.TrunkIds,
|
||||
)
|
||||
// Keep ID empty, so that validation can print "<new>" instead of a non-existent ID in the error.
|
||||
info := &livekit.SIPDispatchRuleInfo{
|
||||
Rule: req.Rule,
|
||||
TrunkIds: req.TrunkIds,
|
||||
InboundNumbers: req.InboundNumbers,
|
||||
HidePhoneNumber: req.HidePhoneNumber,
|
||||
Name: req.Name,
|
||||
Metadata: req.Metadata,
|
||||
Attributes: req.Attributes,
|
||||
RoomConfig: req.RoomConfig,
|
||||
}
|
||||
info := req.DispatchRuleInfo()
|
||||
info.SipDispatchRuleId = ""
|
||||
|
||||
// Validate all rules including the new one first.
|
||||
it, err := ListSIPDispatchRule(ctx, s.store, &livekit.ListSIPDispatchRuleRequest{
|
||||
@@ -357,6 +390,25 @@ func (s *SIPService) CreateSIPDispatchRule(ctx context.Context, req *livekit.Cre
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func (s *SIPService) UpdateSIPDispatchRule(ctx context.Context, req *livekit.UpdateSIPDispatchRuleRequest) (*livekit.SIPDispatchRuleInfo, error) {
|
||||
if err := EnsureSIPAdminPermission(ctx); err != nil {
|
||||
return nil, twirpAuthError(err)
|
||||
}
|
||||
if s.store == nil {
|
||||
return nil, ErrSIPNotConnected
|
||||
}
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
AppendLogFields(ctx,
|
||||
"request", logger.Proto(req),
|
||||
"ruleID", req.SipDispatchRuleId,
|
||||
)
|
||||
|
||||
return nil, twirp.NewError(twirp.Unimplemented, "not implemented")
|
||||
}
|
||||
|
||||
func ListSIPDispatchRule(ctx context.Context, s SIPStore, req *livekit.ListSIPDispatchRuleRequest, add ...*livekit.SIPDispatchRuleInfo) (iters.Iter[*livekit.SIPDispatchRuleInfo], error) {
|
||||
if s == nil {
|
||||
return nil, ErrSIPNotConnected
|
||||
@@ -474,6 +526,9 @@ func (s *SIPService) CreateSIPParticipantRequest(ctx context.Context, req *livek
|
||||
if s.store == nil {
|
||||
return nil, ErrSIPNotConnected
|
||||
}
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
callID := sip.NewCallID()
|
||||
log := logger.GetLogger().WithUnlikelyValues(
|
||||
"callID", callID,
|
||||
@@ -545,6 +600,9 @@ func (s *SIPService) transferSIPParticipantRequest(ctx context.Context, req *liv
|
||||
if err := EnsureAdminPermission(ctx, livekit.RoomName(req.RoomName)); err != nil {
|
||||
return nil, twirpAuthError(err)
|
||||
}
|
||||
if err := req.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := s.roomService.GetParticipant(ctx, &livekit.RoomParticipantIdentity{
|
||||
Room: req.RoomName,
|
||||
|
||||
Reference in New Issue
Block a user