From eb53e1946c103bba16edb5319a10880a2bee6f09 Mon Sep 17 00:00:00 2001 From: bgrozev Date: Thu, 26 Sep 2024 11:11:22 -0500 Subject: [PATCH] ref: Move hasTranscriber out of the detector. (#1173) --- .../main/kotlin/org/jitsi/jicofo/jigasi/JigasiDetector.kt | 6 ------ .../main/kotlin/org/jitsi/jicofo/xmpp/JigasiIqHandler.kt | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/jigasi/JigasiDetector.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/jigasi/JigasiDetector.kt index bfef1021c..1f24fd191 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/jigasi/JigasiDetector.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/jigasi/JigasiDetector.kt @@ -21,7 +21,6 @@ import org.jitsi.jicofo.JicofoConfig import org.jitsi.jicofo.metrics.JicofoMetricsContainer import org.jitsi.jicofo.xmpp.BaseBrewery import org.jitsi.jicofo.xmpp.XmppProvider -import org.jitsi.jicofo.xmpp.muc.ChatRoom import org.jitsi.utils.OrderedJsonObject import org.jitsi.utils.logging2.createLogger import org.jitsi.xmpp.extensions.colibri.ColibriStatsExtension @@ -98,11 +97,6 @@ open class JigasiDetector( transcriberCount.set(getInstanceCount { it.supportsTranscription() }.toLong()) } - fun hasTranscriber(chatRoom: ChatRoom?): Boolean { - return chatRoom?.members?.any { member -> member.isTranscriber } - ?: false - } - /** * The companion object is necessary for the implicit call to this.createLogger() in the super constructor! */ diff --git a/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JigasiIqHandler.kt b/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JigasiIqHandler.kt index bc45e5360..c77df821d 100644 --- a/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JigasiIqHandler.kt +++ b/jicofo/src/main/kotlin/org/jitsi/jicofo/xmpp/JigasiIqHandler.kt @@ -116,7 +116,7 @@ class JigasiIqHandler( exclude: List = emptyList() ) { val selector = if (request.iq.destination == "jitsi_meet_transcribe") { - if (jigasiDetector.hasTranscriber(conference.chatRoom)) { + if (conference.hasTranscriber()) { logger.warn("Request failed, transcriber already available: ${request.iq.toStringOpt()}") IQ.createErrorResponse( request.iq, @@ -256,3 +256,5 @@ class JigasiIqHandler( } } } + +private fun JitsiMeetConference.hasTranscriber(): Boolean = this.chatRoom?.members?.any { it.isTranscriber } ?: false