Adding ability to generate predictable room names#1426
Adding ability to generate predictable room names#1426alexlivekit wants to merge 5 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 90432be The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR 💥 An error occurred when fetching the changed packages and changesets in this PR |
sip/sip.go
Outdated
| if !predictableRoomName { | ||
| suffix = guid.New("") | ||
| } | ||
| room = fmt.Sprintf("%s_%s_%s", pref, from, suffix) |
There was a problem hiding this comment.
If predictableRoomName is true, there will be no suffix. Room name may not be unique? how about we add call ID as the suffix in this case?
39efffe to
f16d7fe
Compare
| t.Run("Direct", func(t *testing.T) { | ||
| d := &livekit.SIPDispatchRuleInfo{ | ||
| SipDispatchRuleId: "rule", | ||
| Rule: newDirectDispatch("room", ""), | ||
| HidePhoneNumber: false, | ||
| InboundNumbers: nil, | ||
| Numbers: nil, | ||
| Name: "", | ||
| Metadata: "rule-meta", | ||
| Attributes: map[string]string{ | ||
| "rule-attr": "1", | ||
| }, | ||
| } | ||
| r := &rpc.EvaluateSIPDispatchRulesRequest{ | ||
| SipCallId: "call-id", | ||
| CallingNumber: "+11112222", | ||
| CallingHost: "sip.example.com", | ||
| CalledNumber: "+3333", | ||
| ExtraAttributes: map[string]string{ | ||
| "prov-attr": "1", | ||
| }, | ||
| } | ||
| tr := &livekit.SIPInboundTrunkInfo{SipTrunkId: "trunk"} | ||
| res, err := EvaluateDispatchRule("p_123", tr, d, r) | ||
| require.NoError(t, err) | ||
| require.Equal(t, &rpc.EvaluateSIPDispatchRulesResponse{ | ||
| ProjectId: "p_123", | ||
| Result: rpc.SIPDispatchResult_ACCEPT, | ||
| SipTrunkId: "trunk", | ||
| SipDispatchRuleId: "rule", | ||
| RoomName: "room", | ||
| ParticipantIdentity: "sip_+11112222", | ||
| ParticipantName: "Phone +11112222", | ||
| ParticipantMetadata: "rule-meta", | ||
| ParticipantAttributes: map[string]string{ | ||
| "rule-attr": "1", | ||
| "prov-attr": "1", | ||
| livekit.AttrSIPCallID: "call-id", | ||
| livekit.AttrSIPTrunkID: "trunk", | ||
| livekit.AttrSIPDispatchRuleID: "rule", | ||
| livekit.AttrSIPPhoneNumber: "+11112222", | ||
| livekit.AttrSIPTrunkNumber: "+3333", | ||
| livekit.AttrSIPHostName: "sip.example.com", | ||
| }, | ||
| }, res) | ||
|
|
||
| d.HidePhoneNumber = true | ||
| res, err = EvaluateDispatchRule("p_123", tr, d, r) | ||
| require.NoError(t, err) | ||
| require.Equal(t, &rpc.EvaluateSIPDispatchRulesResponse{ | ||
| ProjectId: "p_123", | ||
| Result: rpc.SIPDispatchResult_ACCEPT, | ||
| SipTrunkId: "trunk", | ||
| SipDispatchRuleId: "rule", | ||
| RoomName: "room", | ||
| ParticipantIdentity: "sip_c15a31c71649a522", | ||
| ParticipantName: "Phone 2222", | ||
| ParticipantMetadata: "rule-meta", | ||
| ParticipantAttributes: map[string]string{ | ||
| "rule-attr": "1", | ||
| "prov-attr": "1", | ||
| livekit.AttrSIPCallID: "call-id", | ||
| livekit.AttrSIPTrunkID: "trunk", | ||
| livekit.AttrSIPDispatchRuleID: "rule", | ||
| }, | ||
| }, res) | ||
| }) |
There was a problem hiding this comment.
Unchanged from existing tests, just moved from TestEvaluateDispatchRule into TestEvaluateDispatchRule/Direct. GH differ is not ideal here.
| string pin = 2; | ||
|
|
||
| // Optionally append random suffix | ||
| bool no_randomness = 3; |
There was a problem hiding this comment.
when this is set, we are saying it's the user's responsibility to guarantee the uniqueness of room name, right? what happens if two rooms have the same name?
There was a problem hiding this comment.
If two callers specify the same room name, they will be connected to the same room.
Hence really not wanting the default (generate randomness today) to flip (to no unique suffixes) and potentially mess customer flows.
No description provided.