-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Enable transcription based on MUC config form (#1135)
Read room_metadata from the MUC config form, and enable transcription if it is requested.
- Loading branch information
Showing
8 changed files
with
217 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/RoomMetadata.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Jicofo, the Jitsi Conference Focus. | ||
* | ||
* Copyright @ 2024-Present 8x8, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jitsi.jicofo.xmpp.muc | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties | ||
import com.fasterxml.jackson.core.JsonParser | ||
import com.fasterxml.jackson.core.JsonProcessingException | ||
import com.fasterxml.jackson.databind.JsonMappingException | ||
import com.fasterxml.jackson.databind.MapperFeature | ||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper | ||
import com.fasterxml.jackson.module.kotlin.readValue | ||
|
||
/** | ||
* The JSON structure included in the MUC config form from the room_metadata prosody module in jitsi-meet. Includes | ||
* only the fields that we need here in jicofo. | ||
*/ | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
data class RoomMetadata( | ||
val type: String, | ||
val metadata: Metadata? | ||
) { | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
data class Metadata(val recording: Recording?) { | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
data class Recording(val isTranscribingEnabled: Boolean?) | ||
} | ||
|
||
companion object { | ||
private val mapper = jacksonObjectMapper().apply { | ||
enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS) | ||
enable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION) | ||
} | ||
|
||
@Throws(JsonProcessingException::class, JsonMappingException::class) | ||
fun parse(string: String): RoomMetadata { | ||
return mapper.readValue(string) | ||
} | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
jicofo-common/src/test/kotlin/org/jitsi/jicofo/xmpp/muc/RoomMetadataTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Jicofo, the Jitsi Conference Focus. | ||
* | ||
* Copyright @ 2024-Present 8x8, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jitsi.jicofo.xmpp.muc | ||
|
||
import io.kotest.assertions.throwables.shouldThrow | ||
import io.kotest.core.spec.style.ShouldSpec | ||
import io.kotest.matchers.nulls.shouldNotBeNull | ||
import io.kotest.matchers.shouldBe | ||
import io.kotest.matchers.types.shouldBeInstanceOf | ||
|
||
class RoomMetadataTest : ShouldSpec() { | ||
init { | ||
context("Valid") { | ||
context("With isTranscribingEnabled set") { | ||
val parsed = RoomMetadata.parse( | ||
""" | ||
{ | ||
"type": "room_metadata", | ||
"metadata": { | ||
"recording": { | ||
"isTranscribingEnabled": true, | ||
"anotherField": 123 | ||
}, | ||
"anotherField": {} | ||
} | ||
} | ||
""".trimIndent() | ||
) | ||
parsed.shouldBeInstanceOf<RoomMetadata>() | ||
parsed.metadata!!.recording!!.isTranscribingEnabled shouldBe true | ||
} | ||
context("With no recording included") { | ||
|
||
val parsed = RoomMetadata.parse( | ||
""" | ||
{ | ||
"type": "room_metadata", | ||
"metadata": { | ||
"key": { | ||
"key2": "value2" | ||
}, | ||
"anotherField": {} | ||
} | ||
} | ||
""".trimIndent() | ||
) | ||
parsed.shouldBeInstanceOf<RoomMetadata>() | ||
parsed.metadata.shouldNotBeNull() | ||
parsed.metadata?.recording shouldBe null | ||
} | ||
} | ||
context("Invalid") { | ||
context("Missing type") { | ||
shouldThrow<Exception> { | ||
RoomMetadata.parse( | ||
""" | ||
{ "key": 123 } | ||
""".trimIndent() | ||
) | ||
} | ||
} | ||
context("Invalid JSON") { | ||
shouldThrow<Exception> { | ||
RoomMetadata.parse("{") | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters