Skip to content
Snippets Groups Projects
Commit bf2f4c53 authored by Richard Alam's avatar Richard Alam
Browse files

- apply lock settings to viewers and non-listen only users

parent a26d1f0a
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ import org.bigbluebutton.core2.{ MeetingStatus2x }
object LockSettingsUtil {
def muteUserInVoiceConf(liveMeeting: LiveMeeting, outGW: OutMsgRouter, vu: VoiceUserState, mute: Boolean): Unit = {
private 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)
......@@ -19,20 +19,17 @@ object LockSettingsUtil {
outGW.send(msgEvent)
}
def applyMutingOfUsers(mute: Boolean, liveMeeting: LiveMeeting, outGW: OutMsgRouter): Unit = {
private def applyMutingOfUsers(disableMic: 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(liveMeeting, outGW, vu, mute)
} else {
// Only unmute viewers and non-listenOnly users.
if (!vu.listenOnly) {
muteUserInVoiceConf(liveMeeting, outGW, vu, mute)
}
}
if (user.role == Roles.VIEWER_ROLE && !vu.listenOnly) {
// Apply lock setting to users who are not listen only. (ralam dec 6, 2019)
muteUserInVoiceConf(liveMeeting, outGW, vu, disableMic)
}
// Make sure listen only users are muted. (ralam dec 6, 2019)
if (vu.listenOnly && !vu.muted) {
muteUserInVoiceConf(liveMeeting, outGW, vu, true)
}
}
}
......@@ -41,25 +38,21 @@ object LockSettingsUtil {
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 = {
def enforceLockSettingsForVoiceUser(voiceUser: VoiceUserState, liveMeeting: LiveMeeting, outGW: OutMsgRouter): Unit = {
val permissions = MeetingStatus2x.getPermissions(liveMeeting.status)
if (permissions.disableMic) {
Users2x.findWithIntId(liveMeeting.users2x, intUserId).foreach { user =>
Users2x.findWithIntId(liveMeeting.users2x, voiceUser.intId).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)
}
// Make sure that user is muted when lock settings has mic disabled. (ralam dec 6, 2019
if (!voiceUser.muted) {
muteUserInVoiceConf(liveMeeting, outGW, voiceUser, true)
}
}
}
} else {
enforceListenOnlyUserIsMuted(intUserId, liveMeeting, outGW)
enforceListenOnlyUserIsMuted(voiceUser.intId, liveMeeting, outGW)
}
}
......
......@@ -37,7 +37,7 @@ trait UserTalkingInVoiceConfEvtMsgHdlr {
} yield {
// Make sure lock settings are in effect (ralam dec 6, 2019)
LockSettingsUtil.enforceLockSettingsForVoiceUser(
talkingUser.intId,
talkingUser,
liveMeeting,
outGW
)
......
......@@ -97,18 +97,19 @@ object VoiceApp {
if (!muted) {
// Make sure lock settings are in effect (ralam dec 6, 2019)
LockSettingsUtil.enforceLockSettingsForVoiceUser(
mutedUser.intId,
liveMeeting,
outGW
)
} else {
broadcastUserMutedVoiceEvtMsg(
liveMeeting.props.meetingProp.intId,
mutedUser,
liveMeeting.props.voiceProp.voiceConf,
liveMeeting,
outGW
)
}
broadcastUserMutedVoiceEvtMsg(
liveMeeting.props.meetingProp.intId,
mutedUser,
liveMeeting.props.voiceProp.voiceConf,
outGW
)
}
}
......@@ -170,6 +171,20 @@ object VoiceApp {
}
}
private def checkAndEjectOldDuplicateVoiceConfUser(
userid: String,
liveMeeting: LiveMeeting,
outGW: OutMsgRouter
): Unit = {
for {
u <- VoiceUsers.findWithIntId(liveMeeting.voiceUsers, userid)
oldU <- VoiceUsers.removeWithIntId(liveMeeting.voiceUsers, userid)
} yield {
val event = MsgBuilder.buildEjectUserFromVoiceConfSysMsg(liveMeeting.props.meetingProp.intId, liveMeeting.props.voiceProp.voiceConf, oldU.voiceUserId)
outGW.send(event)
}
}
def handleUserJoinedVoiceConfEvtMsg(
liveMeeting: LiveMeeting,
outGW: OutMsgRouter,
......@@ -224,6 +239,8 @@ object VoiceApp {
outGW.send(msgEvent)
}
checkAndEjectOldDuplicateVoiceConfUser(intId, liveMeeting, outGW)
val isListenOnly = if (callerIdName.startsWith("LISTENONLY")) true else false
val voiceUserState = VoiceUserState(
......@@ -263,12 +280,11 @@ object VoiceApp {
// Make sure lock settings are in effect. (ralam dec 6, 2019)
LockSettingsUtil.enforceLockSettingsForVoiceUser(
intId,
voiceUserState,
liveMeeting,
outGW
)
LockSettingsUtil.enforceLockSettingsForVoiceUser(intId, liveMeeting, outGW)
}
def handleUserLeftVoiceConfEvtMsg(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment