Skip to content

Commit

Permalink
squash: Fix bugs introduced while porting.
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrozev committed Oct 15, 2024
1 parent 47439e9 commit 030b809
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
3 changes: 1 addition & 2 deletions jicofo/src/main/kotlin/org/jitsi/jicofo/ConferenceStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package org.jitsi.jicofo
import org.jitsi.jicofo.conference.JitsiMeetConference
import org.jxmpp.jid.EntityBareJid
import java.time.Duration
import java.time.Instant

interface ConferenceStore {
/** Get a list of all conferences. */
Expand All @@ -44,5 +43,5 @@ interface ConferenceStore {
data class PinnedConference(
val conferenceId: String,
val jvbVersion: String,
val expiresAt: Instant
val expiresAt: String
)
2 changes: 1 addition & 1 deletion jicofo/src/main/kotlin/org/jitsi/jicofo/FocusManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class FocusManager(
synchronized(conferencesSyncRoot) {
expirePins(clock.instant())
pinnedConferences.forEach { (conferenceId, p) ->
add(PinnedConference(conferenceId.toString(), p.jvbVersion, p.expiresAt))
add(PinnedConference(conferenceId.toString(), p.jvbVersion, p.expiresAt.toString()))
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion jicofo/src/main/kotlin/org/jitsi/jicofo/JicofoServices.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import org.jitsi.jicofo.xmpp.jingle.JingleStats
import org.jitsi.utils.OrderedJsonObject
import org.jitsi.utils.logging2.createLogger
import org.json.simple.JSONObject
import org.jxmpp.jid.EntityBareJid
import org.jxmpp.jid.impl.JidCreate
import org.jitsi.jicofo.auth.AuthConfig.Companion.config as authConfig

Expand Down Expand Up @@ -239,7 +240,7 @@ class JicofoServices {
put("conference_iq_handler", xmppServices.conferenceIqHandler.debugState)
}

private fun getConferenceDebugState(conferenceId: String) = OrderedJsonObject().apply {
private fun getConferenceDebugState(conferenceId: EntityBareJid) = OrderedJsonObject().apply {
val conference = focusManager.getConference(JidCreate.entityBareFrom(conferenceId))
return conference?.debugState ?: OrderedJsonObject()
}
Expand Down
31 changes: 23 additions & 8 deletions jicofo/src/main/kotlin/org/jitsi/jicofo/ktor/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import org.jivesoftware.smack.packet.IQ
import org.jivesoftware.smack.packet.StanzaError
import org.json.simple.JSONArray
import org.json.simple.JSONObject
import org.jxmpp.jid.EntityBareJid
import org.jxmpp.jid.impl.JidCreate
import org.jxmpp.stringprep.XmppStringprepException
import java.time.Duration
Expand All @@ -68,7 +69,7 @@ class Application(
private val conferenceStore: ConferenceStore,
bridgeSelector: BridgeSelector,
private val getStatsJson: () -> OrderedJsonObject,
private val getDebugState: (full: Boolean, confId: String?) -> OrderedJsonObject
private val getDebugState: (full: Boolean, confId: EntityBareJid?) -> OrderedJsonObject
) {
private val logger = createLogger()
private val server = start()
Expand Down Expand Up @@ -105,7 +106,7 @@ class Application(
if (config.enablePrometheus) {
get("/metrics") {
val accepts =
parseHeaderValue(call.request.headers["Accept"]).sortedBy { it.quality }.map { it.value }
parseHeaderValue(call.request.headers["Accept"]).sortedByDescending { it.quality }.map { it.value }
val (metrics, contentType) = JicofoMetricsContainer.instance.getMetrics(accepts)
call.respondText(metrics, contentType = ContentType.parse(contentType))
}
Expand Down Expand Up @@ -144,7 +145,12 @@ class Application(
private fun Route.conferenceRequest() {
if (config.enableConferenceRequest) {
post("/conference-request/v1") {
val request = call.receive<ConferenceRequest>()
val request = try {
call.receive<ConferenceRequest>()
} catch (e: Exception) {
throw BadRequest(e.message)
}

val response: IQ = try {
conferenceIqHandler.handleConferenceIq(request.toConferenceIq())
} catch (e: XmppStringprepException) {
Expand Down Expand Up @@ -206,7 +212,7 @@ class Application(
)
)
}
get("move-endpoints") {
get("move-fraction") {
call.respond(
moveEndpointsHandler.moveFraction(
call.request.queryParameters["bridge"],
Expand Down Expand Up @@ -242,10 +248,15 @@ class Application(
}
call.respondJson(conferencesJson)
}
get("/conference/{confId}") {
val confId = call.parameters["confId"] ?: throw MissingParameter("conference")
get("/conference/{conference}") {
val conference = call.parameters["conference"] ?: throw MissingParameter("conference")
val conferenceJid = try {
JidCreate.entityBareFrom(conference)
} catch (e: Exception) {
throw BadRequest("Invalid conference ID")
}
call.respondJson(
getDebugState(true, confId)
getDebugState(true, conferenceJid)
)
}
get("xmpp-caps") {
Expand All @@ -265,7 +276,11 @@ class Application(
call.respond(conferenceStore.getPinnedConferences())
}
post("") {
val pin = call.receive<PinJson>()
val pin = try {
call.receive<PinJson>()
} catch (e: Exception) {
throw BadRequest(e.message)
}
val conferenceJid = try {
JidCreate.entityBareFrom(pin.conferenceId)
} catch (e: Exception) {
Expand Down

0 comments on commit 030b809

Please sign in to comment.