Skip to content

Commit 7b84561

Browse files
bgrozevdamencho
authored andcommitted
feat: Read startMuted configuration from room metadata (only).
1 parent 9ff3feb commit 7b84561

5 files changed

Lines changed: 15 additions & 53 deletions

File tree

jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/ChatRoomImpl.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,6 @@ class ChatRoomImpl(
218218
override fun isMemberAllowedToUnmute(jid: Jid, mediaType: MediaType): Boolean =
219219
avModeration(mediaType).isAllowedToUnmute(jid)
220220

221-
internal fun setStartMuted(startAudioMuted: Boolean, startVideoMuted: Boolean) = eventEmitter.fireEvent {
222-
startMutedChanged(startAudioMuted, startVideoMuted)
223-
}
224-
225221
@Throws(SmackException::class, XMPPException::class, InterruptedException::class)
226222
override fun join(): ChatRoomInfo {
227223
// TODO: clean-up the way we figure out what nickname to use.
@@ -290,6 +286,9 @@ class ChatRoomImpl(
290286

291287
override fun setRoomMetadata(roomMetadata: RoomMetadata) {
292288
visitorsLive = roomMetadata.metadata?.visitors?.live == true
289+
roomMetadata.metadata?.startMuted?.let {
290+
eventEmitter.fireEvent { startMutedChanged(it.audio == true, it.video == true) }
291+
}
293292
}
294293

295294
/** Read the fields we care about from [configForm] and update local state. */

jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/ChatRoomMemberImpl.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import org.jitsi.xmpp.extensions.jitsimeet.AudioMutedExtension
2929
import org.jitsi.xmpp.extensions.jitsimeet.FeaturesExtension
3030
import org.jitsi.xmpp.extensions.jitsimeet.JitsiParticipantCodecList
3131
import org.jitsi.xmpp.extensions.jitsimeet.JitsiParticipantRegionPacketExtension
32-
import org.jitsi.xmpp.extensions.jitsimeet.StartMutedPacketExtension
3332
import org.jitsi.xmpp.extensions.jitsimeet.StatsId
3433
import org.jitsi.xmpp.extensions.jitsimeet.VideoMutedExtension
3534
import org.jivesoftware.smack.packet.Presence
@@ -203,13 +202,6 @@ class ChatRoomMemberImpl(
203202
region = it.regionId
204203
}
205204

206-
presence.getExtension(StartMutedPacketExtension::class.java)?.let {
207-
// XXX Is this intended to be allowed for moderators or not?
208-
if (role.hasAdministratorRights()) {
209-
chatRoom.setStartMuted(it.audioMuted, it.videoMuted)
210-
}
211-
}
212-
213205
presence.getExtension(StatsId::class.java)?.let {
214206
statsId = it.statsId
215207
}

jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/MemberRole.kt

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,39 +20,24 @@ package org.jitsi.jicofo.xmpp.muc
2020
import org.jivesoftware.smackx.muc.MUCAffiliation
2121
import org.jivesoftware.smackx.muc.MUCRole
2222

23-
/**
24-
* Indicates roles that a chat room member detains in its containing chat room.
25-
*/
23+
/** Indicates roles that a chat room member detains in its containing chat room. */
2624
enum class MemberRole {
27-
/**
28-
* A role implying the full set of chat room permissions
29-
*/
25+
/** A role implying the full set of chat room permissions */
3026
OWNER,
3127

32-
/**
33-
* A role implying administrative permissions.
34-
*/
35-
ADMINISTRATOR,
36-
37-
/**
38-
* A role implying moderator permissions.
39-
*/
28+
/** A role implying moderator permissions. */
4029
MODERATOR,
4130

42-
/**
43-
* A role implying the ability to send to a chat room
44-
*/
31+
/** A role implying the ability to send to a chat room */
4532
PARTICIPANT,
4633

47-
/**
48-
* A role implying only the ability to watch a chat room.
49-
*/
34+
/** A role implying only the ability to watch a chat room. */
5035
VISITOR;
5136

5237
companion object {
5338
@JvmStatic
5439
fun fromSmack(mucRole: MUCRole?, mucAffiliation: MUCAffiliation?) = when (mucAffiliation) {
55-
MUCAffiliation.admin -> ADMINISTRATOR
40+
MUCAffiliation.admin -> MODERATOR
5641
MUCAffiliation.owner -> OWNER
5742
else -> when (mucRole) {
5843
MUCRole.moderator -> MODERATOR
@@ -63,9 +48,6 @@ enum class MemberRole {
6348
}
6449
}
6550

66-
/**
67-
* Has sufficient rights to moderate (i.e. is MODERATOR, ADMINISTRATOR or OWNER).
68-
*/
51+
/** Has sufficient rights to moderate (i.e. is MODERATOR or OWNER). */
6952
fun MemberRole?.hasModeratorRights() = this != null && this <= MemberRole.MODERATOR
70-
fun MemberRole?.hasAdministratorRights() = this != null && this <= MemberRole.ADMINISTRATOR
7153
fun MemberRole?.hasOwnerRights() = this != null && this <= MemberRole.OWNER

jicofo-common/src/main/kotlin/org/jitsi/jicofo/xmpp/muc/RoomMetadata.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ data class RoomMetadata(
3535
val metadata: Metadata?
3636
) {
3737
@JsonIgnoreProperties(ignoreUnknown = true)
38-
data class Metadata(val visitors: Visitors?) {
38+
data class Metadata(val visitors: Visitors?, val startMuted: StartMuted?) {
3939
@JsonIgnoreProperties(ignoreUnknown = true)
4040
data class Visitors(val live: Boolean?)
41+
42+
@JsonIgnoreProperties(ignoreUnknown = true)
43+
data class StartMuted(val audio: Boolean?, val video: Boolean?)
4144
}
4245

4346
companion object {

jicofo/src/test/kotlin/org/jitsi/jicofo/xmpp/muc/MemberRoleTest.kt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import io.kotest.matchers.booleans.shouldBeFalse
2323
import io.kotest.matchers.booleans.shouldBeTrue
2424
import io.kotest.matchers.ints.shouldBeGreaterThan
2525
import io.kotest.matchers.shouldBe
26-
import org.jitsi.jicofo.xmpp.muc.MemberRole.ADMINISTRATOR
2726
import org.jitsi.jicofo.xmpp.muc.MemberRole.MODERATOR
2827
import org.jitsi.jicofo.xmpp.muc.MemberRole.OWNER
2928
import org.jitsi.jicofo.xmpp.muc.MemberRole.PARTICIPANT
@@ -36,40 +35,27 @@ class MemberRoleTest : ShouldSpec() {
3635
context("Order") {
3736
(VISITOR > PARTICIPANT) shouldBe true
3837
(PARTICIPANT > MODERATOR) shouldBe true
39-
(MODERATOR > ADMINISTRATOR) shouldBe true
40-
(ADMINISTRATOR > OWNER) shouldBe true
4138

4239
VISITOR.compareTo(PARTICIPANT) shouldBeGreaterThan 0
4340
PARTICIPANT.compareTo(MODERATOR) shouldBeGreaterThan 0
44-
MODERATOR.compareTo(ADMINISTRATOR) shouldBeGreaterThan 0
45-
ADMINISTRATOR.compareTo(OWNER) shouldBeGreaterThan 0
4641
}
4742
context("hasModeratorRights") {
4843
VISITOR.hasModeratorRights().shouldBeFalse()
4944
PARTICIPANT.hasModeratorRights().shouldBeFalse()
5045
MODERATOR.hasModeratorRights().shouldBeTrue()
51-
ADMINISTRATOR.hasModeratorRights().shouldBeTrue()
5246
OWNER.hasModeratorRights().shouldBeTrue()
5347
}
54-
context("hasAdministratorRights") {
55-
VISITOR.hasAdministratorRights().shouldBeFalse()
56-
PARTICIPANT.hasAdministratorRights().shouldBeFalse()
57-
MODERATOR.hasAdministratorRights().shouldBeFalse()
58-
ADMINISTRATOR.hasAdministratorRights().shouldBeTrue()
59-
OWNER.hasAdministratorRights().shouldBeTrue()
60-
}
6148
context("hasOwnerRights") {
6249
VISITOR.hasOwnerRights().shouldBeFalse()
6350
PARTICIPANT.hasOwnerRights().shouldBeFalse()
6451
MODERATOR.hasOwnerRights().shouldBeFalse()
65-
ADMINISTRATOR.hasOwnerRights().shouldBeFalse()
6652
OWNER.hasOwnerRights().shouldBeTrue()
6753
}
6854
context("From Smack role and affiliation") {
6955
enumPairsWithNull<MUCRole, MUCAffiliation>().forEach { (mucRole, mucAffiliation) ->
7056
withClue("mucRole=$mucRole, mucAffiliation=$mucAffiliation") {
7157
MemberRole.fromSmack(mucRole, mucAffiliation) shouldBe when (mucAffiliation) {
72-
MUCAffiliation.admin -> ADMINISTRATOR
58+
MUCAffiliation.admin -> MODERATOR
7359
MUCAffiliation.owner -> OWNER
7460
else -> when (mucRole) {
7561
MUCRole.moderator -> MODERATOR

0 commit comments

Comments
 (0)