Skip to content

Commit c536fb6

Browse files
authored
Properly set rule id when updating dispatch rule (#131)
* Properly set rule id when updating dispatch rule * code cleanup
1 parent 0d144eb commit c536fb6

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

.changeset/happy-boxes-add.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"server-sdk-kotlin": patch
3+
---
4+
5+
Properly set rule id when updating dispatch rule

.idea/misc.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/kotlin/io/livekit/server/SipServiceClient.kt

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ import java.util.function.Supplier
4040
*/
4141
class SipServiceClient(
4242
private val service: SipService,
43-
private val apiKey: String,
44-
private val secret: String,
43+
apiKey: String,
44+
secret: String,
4545
) : ServiceClientBase(apiKey, secret) {
4646

4747
/**
@@ -50,6 +50,7 @@ class SipServiceClient(
5050
* See: [SIP Inbound Trunk](https://docs.livekit.io/sip/trunk-inbound/)
5151
*/
5252
@JvmOverloads
53+
@Suppress("unused")
5354
fun createSipInboundTrunk(
5455
name: String,
5556
numbers: List<String>,
@@ -82,6 +83,7 @@ class SipServiceClient(
8283
* See: [SIP Outbound Trunk](https://docs.livekit.io/sip/trunk-outbound/)
8384
*/
8485
@JvmOverloads
86+
@Suppress("unused")
8587
fun createSipOutboundTrunk(
8688
name: String,
8789
address: String,
@@ -115,6 +117,7 @@ class SipServiceClient(
115117
* UpdateSIPInboundTrunk updates an existing SIP Inbound Trunk.
116118
*/
117119
@JvmOverloads
120+
@Suppress("unused")
118121
fun updateSipInboundTrunk(
119122
sipTrunkId: String,
120123
options: UpdateSipInboundTrunkOptions? = null
@@ -145,6 +148,7 @@ class SipServiceClient(
145148
* UpdateSIPOutboundTrunk updates an existing SIP Outbound Trunk.
146149
*/
147150
@JvmOverloads
151+
@Suppress("unused")
148152
fun updateSipOutboundTrunk(
149153
sipTrunkId: String,
150154
options: UpdateSipOutboundTrunkOptions? = null,
@@ -178,6 +182,7 @@ class SipServiceClient(
178182
* See: [SIP Inbound Trunk](https://docs.livekit.io/sip/trunk-inbound/)
179183
*/
180184
@JvmOverloads
185+
@Suppress("unused")
181186
fun listSipInboundTrunk(): Call<List<LivekitSip.SIPInboundTrunkInfo>> {
182187
val request = LivekitSip.ListSIPInboundTrunkRequest.newBuilder().build()
183188

@@ -192,6 +197,7 @@ class SipServiceClient(
192197
* See: [SIP Outbound Trunk](https://docs.livekit.io/sip/trunk-outbound/)
193198
*/
194199
@JvmOverloads
200+
@Suppress("unused")
195201
fun listSipOutboundTrunk(): Call<List<LivekitSip.SIPOutboundTrunkInfo>> {
196202
val request = LivekitSip.ListSIPOutboundTrunkRequest.newBuilder().build()
197203

@@ -204,6 +210,7 @@ class SipServiceClient(
204210
* Deletes a trunk.
205211
*/
206212
@JvmOverloads
213+
@Suppress("unused")
207214
fun deleteSipTrunk(sipTrunkId: String): Call<SIPTrunkInfo> {
208215
val request = with(LivekitSip.DeleteSIPTrunkRequest.newBuilder()) {
209216
this.sipTrunkId = sipTrunkId
@@ -220,6 +227,7 @@ class SipServiceClient(
220227
* See: [Dispatch Rules](https://docs.livekit.io/sip/dispatch-rule/)
221228
*/
222229
@JvmOverloads
230+
@Suppress("unused")
223231
fun createSipDispatchRule(
224232
rule: SipDispatchRule,
225233
options: CreateSipDispatchRuleOptions? = null
@@ -261,31 +269,33 @@ class SipServiceClient(
261269
* UpdateSIPDispatchRule updates an existing SIP Dispatch Rule.
262270
*/
263271
@JvmOverloads
272+
@Suppress("unused")
264273
fun updateSipDispatchRule(
265274
sipDispatchRuleId: String,
266275
options: UpdateSipDispatchRuleOptions? = null
267276
): Call<LivekitSip.SIPDispatchRuleInfo> {
268277
val request = with(LivekitSip.UpdateSIPDispatchRuleRequest.newBuilder()) {
278+
this.sipDispatchRuleId = sipDispatchRuleId
269279
update = with(LivekitSip.SIPDispatchRuleUpdate.newBuilder()) {
270280
options?.let { opt ->
271281
opt.name?.let { this.name = it }
272282
opt.metadata?.let { this.metadata = it }
273283
opt.trunkIds?.let { this.trunkIds = buildListUpdate(it) }
274-
opt.rule?.let {
284+
opt.rule?.let { optRule ->
275285
this.rule = with(SIPDispatchRule.newBuilder()) {
276-
when (it) {
286+
when (optRule) {
277287
is SipDispatchRuleDirect -> {
278288
dispatchRuleDirect = with(SIPDispatchRuleDirect.newBuilder()) {
279-
roomName = it.roomName
280-
it.pin?.let { this.pin = it }
289+
roomName = optRule.roomName
290+
optRule.pin?.let { this.pin = it }
281291
build()
282292
}
283293
}
284294

285295
is SipDispatchRuleIndividual -> {
286296
dispatchRuleIndividual = with(SIPDispatchRuleIndividual.newBuilder()) {
287-
roomPrefix = it.roomPrefix
288-
it.pin?.let { this.pin = it }
297+
roomPrefix = optRule.roomPrefix
298+
optRule.pin?.let { this.pin = it }
289299
build()
290300
}
291301
}
@@ -308,6 +318,7 @@ class SipServiceClient(
308318
*
309319
* See: [Dispatch Rules](https://docs.livekit.io/sip/dispatch-rule/)
310320
*/
321+
@Suppress("unused")
311322
fun listSipDispatchRule(): Call<List<SIPDispatchRuleInfo>> {
312323
val request = LivekitSip.ListSIPDispatchRuleRequest.newBuilder().build()
313324
val credentials = authHeader(emptyList(), listOf(SIPAdmin()))
@@ -320,6 +331,7 @@ class SipServiceClient(
320331
*
321332
* See: [Dispatch Rules](https://docs.livekit.io/sip/dispatch-rule/)
322333
*/
334+
@Suppress("unused")
323335
fun deleteSipDispatchRule(sipDispatchRuleId: String): Call<SIPDispatchRuleInfo> {
324336
val request = with(LivekitSip.DeleteSIPDispatchRuleRequest.newBuilder()) {
325337
this.sipDispatchRuleId = sipDispatchRuleId
@@ -334,6 +346,7 @@ class SipServiceClient(
334346
*
335347
* See: [SIP Participant](https://docs.livekit.io/sip/sip-participant/)
336348
*/
349+
@Suppress("unused")
337350
fun createSipParticipant(
338351
sipTrunkId: String,
339352
number: String,
@@ -377,6 +390,7 @@ class SipServiceClient(
377390
*
378391
* See: [SIP Participant](https://docs.livekit.io/sip/sip-participant/)
379392
*/
393+
@Suppress("unused")
380394
fun transferSipParticipant(
381395
roomName: String,
382396
participantIdentity: String,

0 commit comments

Comments
 (0)