Store role change in session and registered users then propagate the change from akka-apps to bbb-web.

This commit is contained in:
Ghazi Triki 2018-02-08 19:57:57 +01:00
parent 8cda909783
commit 00734d8018
8 changed files with 43 additions and 13 deletions

View File

@ -1,7 +1,7 @@
package org.bigbluebutton.core.apps.users
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.models.{ Roles, Users2x }
import org.bigbluebutton.core.models.{ RegisteredUsers, Roles, Users2x }
import org.bigbluebutton.core.running.{ LiveMeeting, OutMsgRouter }
trait ChangeUserRoleCmdMsgHdlr {
@ -15,7 +15,12 @@ trait ChangeUserRoleCmdMsgHdlr {
uvo <- Users2x.changeRole(liveMeeting.users2x, msg.body.userId, msg.body.role)
} yield {
val userRole = if (uvo.role == Roles.MODERATOR_ROLE) "MODERATOR" else "VIEWER"
for {
// Update guest from waiting list
u <- RegisteredUsers.findWithUserId(uvo.intId, liveMeeting.registeredUsers)
} yield {
RegisteredUsers.updateUserRole(liveMeeting.registeredUsers, u, userRole)
}
val event = buildUserRoleChangedEvtMsg(liveMeeting.props.meetingProp.intId, msg.body.userId,
msg.body.changedBy, userRole)

View File

@ -33,14 +33,6 @@ object RegisteredUsers {
} yield user
}
def updateRegUser(uvo: UserVO, users: RegisteredUsers) {
for {
ru <- RegisteredUsers.findWithUserId(uvo.id, users)
regUser = new RegisteredUser(uvo.id, uvo.externalId, uvo.name, uvo.role, ru.authToken,
uvo.avatarURL, uvo.guest, uvo.authed, uvo.waitingForAcceptance)
} yield users.save(regUser)
}
def add(users: RegisteredUsers, user: RegisteredUser): Vector[RegisteredUser] = {
users.save(user)
}
@ -55,6 +47,13 @@ object RegisteredUsers {
users.save(u)
u
}
def updateUserRole(users: RegisteredUsers, user: RegisteredUser,
role: String): RegisteredUser = {
val u = user.modify(_.role).setTo(role)
users.save(u)
u
}
}

View File

@ -28,6 +28,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.Set;
import java.util.concurrent.*;
@ -102,6 +103,18 @@ public class MeetingService implements MessageListener {
public void addUserSession(String token, UserSession user) {
sessions.put(token, user);
}
public String getTokenByUserId(String internalUserId) {
String result = null;
for (Entry<String, UserSession> e : sessions.entrySet()) {
String token = e.getKey();
UserSession userSession = e.getValue();
if (userSession.internalUserId.equals(internalUserId)) {
result = token;
}
}
return result;
}
public void registerUser(String meetingID, String internalUserId,
String fullname, String role, String externUserID,
@ -782,6 +795,12 @@ public class MeetingService implements MessageListener {
User user = m.getUserById(message.userId);
if (user != null) {
user.setRole(message.role);
String sessionToken = getTokenByUserId(user.getInternalUserId());
if (sessionToken != null) {
UserSession userSession = getUserSession(sessionToken);
userSession.role = message.role;
sessions.replace(sessionToken, userSession);
}
log.debug("Setting new role in meeting " + message.meetingId + " for participant:" + user.getFullname());
return;
}

View File

@ -83,6 +83,8 @@ class ReceivedJsonMsgHdlrActor(val msgFromAkkaAppsEventBus: MsgFromAkkaAppsEvent
route[UserBroadcastCamStartedEvtMsg](envelope, jsonNode)
case UserBroadcastCamStoppedEvtMsg.NAME =>
route[UserBroadcastCamStoppedEvtMsg](envelope, jsonNode)
case UserRoleChangedEvtMsg.NAME =>
route[UserRoleChangedEvtMsg](envelope, jsonNode)
case CreateBreakoutRoomSysCmdMsg.NAME =>
route[CreateBreakoutRoomSysCmdMsg](envelope, jsonNode)

View File

@ -32,6 +32,7 @@ class OldMeetingMsgHdlrActor(val olgMsgGW: OldMessageReceivedGW)
case m: UserLeftMeetingEvtMsg => handleUserLeftMeetingEvtMsg(m)
case m: UserJoinedVoiceConfToClientEvtMsg => handleUserJoinedVoiceConfToClientEvtMsg(m)
case m: UserLeftVoiceConfToClientEvtMsg => handleUserLeftVoiceConfToClientEvtMsg(m)
case m: UserRoleChangedEvtMsg => handleUserRoleChangedEvtMsg(m)
case m: UserBroadcastCamStartedEvtMsg => handleUserBroadcastCamStartedEvtMsg(m)
case m: UserBroadcastCamStoppedEvtMsg => handleUserBroadcastCamStoppedEvtMsg(m)
case m: CreateBreakoutRoomSysCmdMsg => handleCreateBreakoutRoomSysCmdMsg(m)
@ -113,6 +114,10 @@ class OldMeetingMsgHdlrActor(val olgMsgGW: OldMessageReceivedGW)
def handleUserBroadcastCamStoppedEvtMsg(msg: UserBroadcastCamStoppedEvtMsg): Unit = {
olgMsgGW.handle(new UserUnsharedWebcam(msg.header.meetingId, msg.body.userId, msg.body.stream))
}
def handleUserRoleChangedEvtMsg(msg: UserRoleChangedEvtMsg): Unit = {
olgMsgGW.handle(new UserRoleChanged(msg.header.meetingId, msg.body.userId, msg.body.role))
}
}

View File

@ -24,8 +24,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:common="org.bigbluebutton.common.*"
verticalScrollPolicy="off" horizontalScrollPolicy="off"
dataChange="dataChangeHandler(event)"
>
dataChange="dataChangeHandler(event)">
<fx:Script>
<![CDATA[

View File

@ -91,6 +91,7 @@
//rest rolledOver when the data changes because onRollOut wont be called if the row moves
if (data != null) {
updateButtons();
validateNow();
}
}

View File

@ -421,7 +421,7 @@ $Id: $
}
}
private function setRoomLocked(e:Event = null) {
private function setRoomLocked(e:Event = null):void {
var lockSettings:LockSettingsVO = UsersUtil.getLockSettings();
roomLocked = (lockSettings.isAnythingLocked() || LiveMeeting.inst().meeting.webcamsOnlyForModerator) && (lockSettings.getLockOnJoin() || UsersUtil.isAnyoneLocked());
}