diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/LockSettingsUtil.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/LockSettingsUtil.scala index 47cef4d65df458beb8c82ede53719db98b109e0d..66740b27ada4c5819c567fcd1d8d6c3e30ee1877 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/LockSettingsUtil.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/LockSettingsUtil.scala @@ -7,31 +7,30 @@ import org.bigbluebutton.core2.{ MeetingStatus2x } object LockSettingsUtil { - def applyMutingOfUsers(mute: Boolean, liveMeeting: LiveMeeting, outGW: OutMsgRouter): Unit = { - - def muteUserInVoiceConf(vu: VoiceUserState, mute: Boolean): Unit = { - val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, liveMeeting.props.meetingProp.intId, vu.intId) - val envelope = BbbCoreEnvelope(MuteUserInVoiceConfSysMsg.NAME, routing) - val header = BbbCoreHeaderWithMeetingId(MuteUserInVoiceConfSysMsg.NAME, liveMeeting.props.meetingProp.intId) + def muteUserInVoiceConf(liveMeeting: LiveMeeting, outGW: OutMsgRouter, vu: VoiceUserState, mute: Boolean): Unit = { + val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, liveMeeting.props.meetingProp.intId, vu.intId) + val envelope = BbbCoreEnvelope(MuteUserInVoiceConfSysMsg.NAME, routing) + val header = BbbCoreHeaderWithMeetingId(MuteUserInVoiceConfSysMsg.NAME, liveMeeting.props.meetingProp.intId) - val body = MuteUserInVoiceConfSysMsgBody(liveMeeting.props.voiceProp.voiceConf, vu.voiceUserId, mute) - val event = MuteUserInVoiceConfSysMsg(header, body) - val msgEvent = BbbCommonEnvCoreMsg(envelope, event) + val body = MuteUserInVoiceConfSysMsgBody(liveMeeting.props.voiceProp.voiceConf, vu.voiceUserId, mute) + val event = MuteUserInVoiceConfSysMsg(header, body) + val msgEvent = BbbCommonEnvCoreMsg(envelope, event) - outGW.send(msgEvent) - } + outGW.send(msgEvent) + } + def applyMutingOfUsers(mute: Boolean, liveMeeting: LiveMeeting, outGW: OutMsgRouter): Unit = { VoiceUsers.findAll(liveMeeting.voiceUsers) foreach { vu => Users2x.findWithIntId(liveMeeting.users2x, vu.intId).foreach { user => if (user.role == Roles.VIEWER_ROLE) { if (mute) { // Mute everyone. We also mute listenOnly users as sledgehammer to make sure // audio can't be transmitted. (ralam dec 6, 2019) - muteUserInVoiceConf(vu, mute) + muteUserInVoiceConf(liveMeeting, outGW, vu, mute) } else { // Only unmute viewers and non-listenOnly users. if (!vu.listenOnly) { - muteUserInVoiceConf(vu, mute) + muteUserInVoiceConf(liveMeeting, outGW, vu, mute) } } } @@ -39,9 +38,36 @@ object LockSettingsUtil { } } - def enforceLockSettingsForVoice(liveMeeting: LiveMeeting, outGW: OutMsgRouter): Unit = { + def enforceLockSettingsForAllVoiceUsers(liveMeeting: LiveMeeting, outGW: OutMsgRouter): Unit = { val permissions = MeetingStatus2x.getPermissions(liveMeeting.status) applyMutingOfUsers(permissions.disableMic, liveMeeting, outGW) } + + def enforceLockSettingsForVoiceUser(intUserId: String, liveMeeting: LiveMeeting, outGW: OutMsgRouter): Unit = { + val permissions = MeetingStatus2x.getPermissions(liveMeeting.status) + if (permissions.disableMic) { + Users2x.findWithIntId(liveMeeting.users2x, intUserId).foreach { user => + if (user.role == Roles.VIEWER_ROLE) { + val voiceUser = VoiceUsers.findWithIntId(liveMeeting.voiceUsers, intUserId) + voiceUser.foreach { vu => + // Make sure that user is muted when lock settings has mic disabled. (ralam dec 6, 2019 + if (!vu.muted) { + muteUserInVoiceConf(liveMeeting, outGW, vu, true) + } + } + } + } + } + } + + def enforceListenOnlyUserIsMuted(intUserId: String, liveMeeting: LiveMeeting, outGW: OutMsgRouter): Unit = { + val voiceUser = VoiceUsers.findWithIntId(liveMeeting.voiceUsers, intUserId) + voiceUser.foreach { vu => + // Make sure that listen only user is muted. (ralam dec 6, 2019 + if (vu.listenOnly && !vu.muted) { + muteUserInVoiceConf(liveMeeting, outGW, vu, true) + } + } + } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/ChangeLockSettingsInMeetingCmdMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/ChangeLockSettingsInMeetingCmdMsgHdlr.scala index df4a40a6e749ad2ec23ab888683e26449977fbf6..c0de4bea16edcf843998504d08357d47816d79d5 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/ChangeLockSettingsInMeetingCmdMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/ChangeLockSettingsInMeetingCmdMsgHdlr.scala @@ -37,7 +37,7 @@ trait ChangeLockSettingsInMeetingCmdMsgHdlr extends RightsManagementTrait { MeetingStatus2x.setPermissions(liveMeeting.status, settings) - LockSettingsUtil.enforceLockSettingsForVoice(liveMeeting, outGW) + LockSettingsUtil.enforceLockSettingsForAllVoiceUsers(liveMeeting, outGW) val routing = Routing.addMsgToClientRouting( MessageTypes.BROADCAST_TO_MEETING, diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/VoiceApp.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/VoiceApp.scala index 35f0a3bcf2ac323c60bb3395b85db9a66e43b2b7..da28c40d9a7505cf54d19c82494c296cd56c6129 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/VoiceApp.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/VoiceApp.scala @@ -1,10 +1,11 @@ package org.bigbluebutton.core.apps.voice -import org.bigbluebutton.common2.msgs.{ BbbClientMsgHeader, BbbCommonEnvCoreMsg, BbbCoreEnvelope, ConfVoiceUser, MessageTypes, Routing, UserJoinedVoiceConfToClientEvtMsg, UserJoinedVoiceConfToClientEvtMsgBody, UserLeftVoiceConfToClientEvtMsg, UserLeftVoiceConfToClientEvtMsgBody, UserMutedVoiceEvtMsg, UserMutedVoiceEvtMsgBody } +import org.bigbluebutton.LockSettingsUtil +import org.bigbluebutton.common2.msgs.{BbbClientMsgHeader, BbbCommonEnvCoreMsg, BbbCoreEnvelope, ConfVoiceUser, MessageTypes, Routing, UserJoinedVoiceConfToClientEvtMsg, UserJoinedVoiceConfToClientEvtMsgBody, UserLeftVoiceConfToClientEvtMsg, UserLeftVoiceConfToClientEvtMsgBody, UserMutedVoiceEvtMsg, UserMutedVoiceEvtMsgBody} import org.bigbluebutton.core.apps.breakout.BreakoutHdlrHelpers import org.bigbluebutton.core.bus.InternalEventBus -import org.bigbluebutton.core.models.{ VoiceUserState, VoiceUsers } -import org.bigbluebutton.core.running.{ LiveMeeting, OutMsgRouter } +import org.bigbluebutton.core.models.{VoiceUserState, VoiceUsers} +import org.bigbluebutton.core.running.{LiveMeeting, OutMsgRouter} import org.bigbluebutton.core2.MeetingStatus2x import org.bigbluebutton.core2.message.senders.MsgBuilder @@ -250,6 +251,12 @@ object VoiceApp { ) outGW.send(event) } + + LockSettingsUtil.enforceListenOnlyUserIsMuted(intId, + liveMeeting, + outGW) + + LockSettingsUtil.enforceLockSettingsForVoiceUser(intId, liveMeeting, outGW) } def handleUserLeftVoiceConfEvtMsg(