Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ class ChatRoomImpl(
override fun isMemberAllowedToUnmute(jid: Jid, mediaType: MediaType): Boolean =
avModeration(mediaType).isAllowedToUnmute(jid)

internal fun setStartMuted(startAudioMuted: Boolean, startVideoMuted: Boolean) = eventEmitter.fireEvent {
startMutedChanged(startAudioMuted, startVideoMuted)
}

@Throws(SmackException::class, XMPPException::class, InterruptedException::class)
override fun join(): ChatRoomInfo {
// TODO: clean-up the way we figure out what nickname to use.
Expand Down Expand Up @@ -290,6 +286,9 @@ class ChatRoomImpl(

override fun setRoomMetadata(roomMetadata: RoomMetadata) {
visitorsLive = roomMetadata.metadata?.visitors?.live == true
roomMetadata.metadata?.startMuted?.let {
eventEmitter.fireEvent { startMutedChanged(it.audio == true, it.video == true) }
}
}

/** Read the fields we care about from [configForm] and update local state. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import org.jitsi.xmpp.extensions.jitsimeet.AudioMutedExtension
import org.jitsi.xmpp.extensions.jitsimeet.FeaturesExtension
import org.jitsi.xmpp.extensions.jitsimeet.JitsiParticipantCodecList
import org.jitsi.xmpp.extensions.jitsimeet.JitsiParticipantRegionPacketExtension
import org.jitsi.xmpp.extensions.jitsimeet.StartMutedPacketExtension
import org.jitsi.xmpp.extensions.jitsimeet.StatsId
import org.jitsi.xmpp.extensions.jitsimeet.VideoMutedExtension
import org.jivesoftware.smack.packet.Presence
Expand Down Expand Up @@ -203,13 +202,6 @@ class ChatRoomMemberImpl(
region = it.regionId
}

presence.getExtension(StartMutedPacketExtension::class.java)?.let {
// XXX Is this intended to be allowed for moderators or not?
if (role.hasAdministratorRights()) {
chatRoom.setStartMuted(it.audioMuted, it.videoMuted)
}
}

presence.getExtension(StatsId::class.java)?.let {
statsId = it.statsId
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,24 @@ package org.jitsi.jicofo.xmpp.muc
import org.jivesoftware.smackx.muc.MUCAffiliation
import org.jivesoftware.smackx.muc.MUCRole

/**
* Indicates roles that a chat room member detains in its containing chat room.
*/
/** Indicates roles that a chat room member detains in its containing chat room. */
enum class MemberRole {
/**
* A role implying the full set of chat room permissions
*/
/** A role implying the full set of chat room permissions */
OWNER,

/**
* A role implying administrative permissions.
*/
ADMINISTRATOR,

/**
* A role implying moderator permissions.
*/
/** A role implying moderator permissions. */
MODERATOR,

/**
* A role implying the ability to send to a chat room
*/
/** A role implying the ability to send to a chat room */
PARTICIPANT,

/**
* A role implying only the ability to watch a chat room.
*/
/** A role implying only the ability to watch a chat room. */
VISITOR;

companion object {
@JvmStatic
fun fromSmack(mucRole: MUCRole?, mucAffiliation: MUCAffiliation?) = when (mucAffiliation) {
MUCAffiliation.admin -> ADMINISTRATOR
MUCAffiliation.admin -> MODERATOR
MUCAffiliation.owner -> OWNER
else -> when (mucRole) {
MUCRole.moderator -> MODERATOR
Expand All @@ -63,9 +48,6 @@ enum class MemberRole {
}
}

/**
* Has sufficient rights to moderate (i.e. is MODERATOR, ADMINISTRATOR or OWNER).
*/
/** Has sufficient rights to moderate (i.e. is MODERATOR or OWNER). */
fun MemberRole?.hasModeratorRights() = this != null && this <= MemberRole.MODERATOR
fun MemberRole?.hasAdministratorRights() = this != null && this <= MemberRole.ADMINISTRATOR
fun MemberRole?.hasOwnerRights() = this != null && this <= MemberRole.OWNER
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ data class RoomMetadata(
val metadata: Metadata?
) {
@JsonIgnoreProperties(ignoreUnknown = true)
data class Metadata(val visitors: Visitors?) {
data class Metadata(val visitors: Visitors?, val startMuted: StartMuted?) {
@JsonIgnoreProperties(ignoreUnknown = true)
data class Visitors(val live: Boolean?)

@JsonIgnoreProperties(ignoreUnknown = true)
data class StartMuted(val audio: Boolean?, val video: Boolean?)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import io.kotest.matchers.booleans.shouldBeFalse
import io.kotest.matchers.booleans.shouldBeTrue
import io.kotest.matchers.ints.shouldBeGreaterThan
import io.kotest.matchers.shouldBe
import org.jitsi.jicofo.xmpp.muc.MemberRole.ADMINISTRATOR
import org.jitsi.jicofo.xmpp.muc.MemberRole.MODERATOR
import org.jitsi.jicofo.xmpp.muc.MemberRole.OWNER
import org.jitsi.jicofo.xmpp.muc.MemberRole.PARTICIPANT
Expand All @@ -36,40 +35,27 @@ class MemberRoleTest : ShouldSpec() {
context("Order") {
(VISITOR > PARTICIPANT) shouldBe true
(PARTICIPANT > MODERATOR) shouldBe true
(MODERATOR > ADMINISTRATOR) shouldBe true
(ADMINISTRATOR > OWNER) shouldBe true

VISITOR.compareTo(PARTICIPANT) shouldBeGreaterThan 0
PARTICIPANT.compareTo(MODERATOR) shouldBeGreaterThan 0
MODERATOR.compareTo(ADMINISTRATOR) shouldBeGreaterThan 0
ADMINISTRATOR.compareTo(OWNER) shouldBeGreaterThan 0
}
context("hasModeratorRights") {
VISITOR.hasModeratorRights().shouldBeFalse()
PARTICIPANT.hasModeratorRights().shouldBeFalse()
MODERATOR.hasModeratorRights().shouldBeTrue()
ADMINISTRATOR.hasModeratorRights().shouldBeTrue()
OWNER.hasModeratorRights().shouldBeTrue()
}
context("hasAdministratorRights") {
VISITOR.hasAdministratorRights().shouldBeFalse()
PARTICIPANT.hasAdministratorRights().shouldBeFalse()
MODERATOR.hasAdministratorRights().shouldBeFalse()
ADMINISTRATOR.hasAdministratorRights().shouldBeTrue()
OWNER.hasAdministratorRights().shouldBeTrue()
}
context("hasOwnerRights") {
VISITOR.hasOwnerRights().shouldBeFalse()
PARTICIPANT.hasOwnerRights().shouldBeFalse()
MODERATOR.hasOwnerRights().shouldBeFalse()
ADMINISTRATOR.hasOwnerRights().shouldBeFalse()
OWNER.hasOwnerRights().shouldBeTrue()
}
context("From Smack role and affiliation") {
enumPairsWithNull<MUCRole, MUCAffiliation>().forEach { (mucRole, mucAffiliation) ->
withClue("mucRole=$mucRole, mucAffiliation=$mucAffiliation") {
MemberRole.fromSmack(mucRole, mucAffiliation) shouldBe when (mucAffiliation) {
MUCAffiliation.admin -> ADMINISTRATOR
MUCAffiliation.admin -> MODERATOR
MUCAffiliation.owner -> OWNER
else -> when (mucRole) {
MUCRole.moderator -> MODERATOR
Expand Down