Merge pull request #4632 from ritzalam/guest-manager-remember

- set guest policy when remember choice is checked
This commit is contained in:
Anton Georgiev 2017-11-07 19:05:54 -02:00 committed by GitHub
commit af578111bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 100 additions and 51 deletions

View File

@ -57,13 +57,15 @@ trait RegisterUserReqMsgHdlr {
guestStatus match {
case GuestStatus.ALLOW =>
// do nothing. Let the user go through.
val g = GuestApprovedVO(regUser.id, GuestStatus.ALLOW)
UsersApp.approveOrRejectGuest(liveMeeting, outGW, g, "SYSTEM")
case GuestStatus.WAIT =>
val guest = GuestWaiting(regUser.id, regUser.name, regUser.role)
addGuestToWaitingForApproval(guest, liveMeeting.guestsWaiting)
notifyModeratorsOfGuestWaiting(Vector(guest), liveMeeting.users2x, liveMeeting.props.meetingProp.intId)
case GuestStatus.DENY =>
log.info("**** TODO: Handle DENY Guest Status")
val g = GuestApprovedVO(regUser.id, GuestStatus.DENY)
UsersApp.approveOrRejectGuest(liveMeeting, outGW, g, "SYSTEM")
}
}

View File

@ -4,8 +4,9 @@ import akka.actor.ActorContext
import akka.event.Logging
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.bus.InternalEventBus
import org.bigbluebutton.core.models.{ Roles, Users2x }
import org.bigbluebutton.core.models._
import org.bigbluebutton.core.running.{ LiveMeeting, OutMsgRouter }
import org.bigbluebutton.core2.message.senders.MsgBuilder
object UsersApp {
def broadcastAddUserToPresenterGroup(meetingId: String, userId: String, requesterId: String,
@ -29,6 +30,25 @@ object UsersApp {
)
}
def approveOrRejectGuest(liveMeeting: LiveMeeting, outGW: OutMsgRouter,
guest: GuestApprovedVO, approvedBy: String): Unit = {
for {
u <- RegisteredUsers.findWithUserId(guest.guest, liveMeeting.registeredUsers)
} yield {
RegisteredUsers.setWaitingForApproval(liveMeeting.registeredUsers, u, guest.status)
// send message to user that he has been approved
val event = MsgBuilder.buildGuestApprovedEvtMsg(
liveMeeting.props.meetingProp.intId,
guest.guest, guest.status, approvedBy
)
outGW.send(event)
}
}
}
class UsersApp(

View File

@ -97,6 +97,8 @@ class AnalyticsActor extends Actor with ActorLogging {
case m: GuestsWaitingApprovedMsg => logMessage(msg)
case m: GuestsWaitingApprovedEvtMsg => logMessage(msg)
case m: GuestsWaitingForApprovalEvtMsg => logMessage(msg)
case m: SetGuestPolicyCmdMsg => logMessage(msg)
case m: GuestPolicyChangedEvtMsg => logMessage(msg)
case m: ClientToServerLatencyTracerMsg => traceMessage(msg)
case m: ServerToClientLatencyTracerMsg => traceMessage(msg)

View File

@ -1,6 +1,7 @@
package org.bigbluebutton.core2.message.handlers.guests
import org.bigbluebutton.common2.msgs.{ GuestApprovedVO, GuestsWaitingApprovedMsg }
import org.bigbluebutton.core.apps.users.UsersApp
import org.bigbluebutton.core.models._
import org.bigbluebutton.core.running.{ BaseMeetingActor, HandlerHelpers, LiveMeeting, OutMsgRouter }
import org.bigbluebutton.core2.message.senders.MsgBuilder
@ -13,32 +14,17 @@ trait GuestsWaitingApprovedMsgHdlr extends HandlerHelpers {
def handleGuestsWaitingApprovedMsg(msg: GuestsWaitingApprovedMsg): Unit = {
msg.body.guests foreach { g =>
approveOrRejectGuest(g, msg.body.approvedBy)
for {
// Remove guest from waiting list
_ <- GuestsWaiting.remove(liveMeeting.guestsWaiting, g.guest)
} yield {
UsersApp.approveOrRejectGuest(liveMeeting, outGW, g, msg.body.approvedBy)
}
}
notifyModeratorsOfGuestsApproval(msg.body.guests, msg.body.approvedBy)
}
def approveOrRejectGuest(guest: GuestApprovedVO, approvedBy: String): Unit = {
for {
// Remove guest from waiting list
g <- GuestsWaiting.remove(liveMeeting.guestsWaiting, guest.guest)
u <- RegisteredUsers.findWithUserId(g.intId, liveMeeting.registeredUsers)
} yield {
RegisteredUsers.setWaitingForApproval(liveMeeting.registeredUsers, u, GuestStatus.ALLOW)
// send message to user that he has been approved
val event = MsgBuilder.buildGuestApprovedEvtMsg(
liveMeeting.props.meetingProp.intId,
g.intId, guest.status, approvedBy
)
outGW.send(event)
}
}
def notifyModeratorsOfGuestsApproval(guests: Vector[GuestApprovedVO], approvedBy: String): Unit = {
val mods = Users2x.findAll(liveMeeting.users2x).filter(p => p.role == Roles.MODERATOR_ROLE)
mods foreach { m =>

View File

@ -873,6 +873,8 @@ public class MeetingService implements MessageListener {
processPresentationUploadToken((PresentationUploadToken) message);
} else if (message instanceof GuestStatusChangedEventMsg) {
processGuestStatusChangedEventMsg((GuestStatusChangedEventMsg) message);
} else if (message instanceof GuestPolicyChanged) {
processGuestPolicyChanged((GuestPolicyChanged) message);
} else if (message instanceof RecordChapterBreak) {
processRecordingChapterBreak((RecordChapterBreak) message);
}
@ -882,6 +884,13 @@ public class MeetingService implements MessageListener {
runExec.execute(task);
}
public void processGuestPolicyChanged(GuestPolicyChanged msg) {
Meeting m = getMeeting(msg.meetingId);
if (m != null) {
m.setGuestPolicy(msg.policy);
}
}
public void processRecordingChapterBreak(RecordChapterBreak msg) {
recordingService.kickOffRecordingChapterBreak(msg.meetingId, msg.timestamp);
}

View File

@ -293,6 +293,10 @@ public class Meeting {
return defaultAvatarURL;
}
public void setGuestPolicy(String policy) {
guestPolicy = policy;
}
public String getGuestPolicy() {
return guestPolicy;
}

View File

@ -0,0 +1,11 @@
package org.bigbluebutton.api.messaging.messages;
public class GuestPolicyChanged implements IMessage {
public final String meetingId;
public final String policy;
public GuestPolicyChanged(String meetingId, String policy) {
this.meetingId = meetingId;
this.policy = policy;
}
}

View File

@ -89,6 +89,8 @@ class ReceivedJsonMsgHdlrActor(val msgFromAkkaAppsEventBus: MsgFromAkkaAppsEvent
route[PresentationUploadTokenSysPubMsg](envelope, jsonNode)
case GuestsWaitingApprovedEvtMsg.NAME =>
route[GuestsWaitingApprovedEvtMsg](envelope, jsonNode)
case GuestPolicyChangedEvtMsg.NAME =>
route[GuestPolicyChangedEvtMsg](envelope, jsonNode)
case RecordingChapterBreakSysMsg.NAME =>
route[RecordingChapterBreakSysMsg](envelope, jsonNode)
case _ =>

View File

@ -41,12 +41,17 @@ class OldMeetingMsgHdlrActor(val olgMsgGW: OldMessageReceivedGW)
case m: CreateBreakoutRoomSysCmdMsg => handleCreateBreakoutRoomSysCmdMsg(m)
case m: PresentationUploadTokenSysPubMsg => handlePresentationUploadTokenSysPubMsg(m)
case m: GuestsWaitingApprovedEvtMsg => handleGuestsWaitingApprovedEvtMsg(m)
case m: GuestPolicyChangedEvtMsg => handleGuestPolicyChangedEvtMsg(m)
case m: RecordingChapterBreakSysMsg => handleRecordingChapterBreakSysMsg(m)
case _ => log.error("***** Cannot handle " + msg.envelope.name)
}
}
def handleGuestPolicyChangedEvtMsg(msg: GuestPolicyChangedEvtMsg): Unit = {
olgMsgGW.handle(new GuestPolicyChanged(msg.header.meetingId, msg.body.policy))
}
def handleRecordingChapterBreakSysMsg(msg: RecordingChapterBreakSysMsg): Unit = {
olgMsgGW.handle(new RecordChapterBreak(msg.body.meetingId, msg.body.timestamp))
}

View File

@ -38,7 +38,9 @@ $Id: $
<fx:Script>
<![CDATA[
import com.asfusion.mate.events.Dispatcher;
import mx.collections.ArrayCollection;
import org.bigbluebutton.core.PopUpUtil;
import org.bigbluebutton.core.model.LiveMeeting;
import org.bigbluebutton.core.model.users.GuestWaiting;
@ -56,7 +58,7 @@ $Id: $
private var dispatcher:Dispatcher = new Dispatcher();
public function refreshGuestView():void {
guestUsers = new ArrayCollection(LiveMeeting.inst().guestsWaiting.getGuests());
guestUsers = new ArrayCollection(LiveMeeting.inst().guestsWaiting.getGuests());
}
public function sendResponseToAllGuests(approved:Boolean):void {
@ -72,14 +74,10 @@ $Id: $
dispatcher.dispatchEvent(respCommand);
}
public function sendResponseToAllGuestsCheckBox(resp:Boolean):void {
if(rememberCheckBox.selected) {
public function sendResponseToAllGuestsCheckBox(resp:Boolean, guestPolicy: String):void {
if (rememberCheckBox.selected) {
var event:BBBEvent = new BBBEvent(BBBEvent.BROADCAST_GUEST_POLICY);
if (resp) {
event.payload['guestPolicy'] = GuestPolicy.ALWAYS_ACCEPT;
} else {
event.payload['guestPolicy'] = GuestPolicy.ALWAYS_DENY;
}
event.payload['guestPolicy'] = guestPolicy;
dispatcher.dispatchEvent(event);
}
sendResponseToAllGuests(resp);
@ -97,17 +95,17 @@ $Id: $
closeWindow();
}
public function remove(userid:String):void {
refreshGuestView();
var removeGuestEvent:RemoveGuestEvent = new RemoveGuestEvent();
removeGuestEvent.userid = userid;
dispatcher.dispatchEvent(removeGuestEvent);
if (guestUsers.length == 0) {
closeWindow();
}
public function remove(userid:String):void {
refreshGuestView();
var removeGuestEvent:RemoveGuestEvent = new RemoveGuestEvent();
removeGuestEvent.userid = userid;
dispatcher.dispatchEvent(removeGuestEvent);
if (guestUsers.length == 0) {
closeWindow();
}
}
public function closeWindow():void {
PopUpUtil.removePopUp(this);
@ -116,31 +114,40 @@ $Id: $
]]>
</fx:Script>
<mx:VBox height="100%" width="100%" paddingTop="15" paddingBottom="15" verticalGap="15" horizontalAlign="center">
<mx:VBox height="100%" width="100%" paddingTop="15" paddingBottom="15"
verticalGap="15" horizontalAlign="center">
<common:AdvancedLabel text="{ResourceUtil.getInstance().getString('bbb.guests.pending.title')}"
styleName="titleWindowStyle"
width="{this.width - 40}" />
<mx:HBox paddingLeft="20" paddingRight="20" horizontalGap="20" width="100%" height="100%">
<mx:HBox paddingLeft="20" paddingRight="20" horizontalGap="20"
width="100%" height="100%">
<mx:VBox width="200" height="100%">
<mx:VBox width="100%">
<mx:Button id="allowAllAuthBtn" styleName="mainActionButton"
label="{ResourceUtil.getInstance().getString('bbb.guests.allowAllAuthenticated.label')}"
width="100%" click="sendResponseToAllGuestsCheckBox(true)" toolTip="{allowEveryoneBtn.label}"/>
width="100%"
click="sendResponseToAllGuestsCheckBox(true, GuestPolicy.ALWAYS_ACCEPT_AUTH)"
toolTip="{allowEveryoneBtn.label}"/>
<mx:Button id="allowAllGuestsBtn" styleName="mainActionButton"
label="{ResourceUtil.getInstance().getString('bbb.guests.allowAllGuestsBtn.label')}"
width="100%" click="sendResponseToAllGuestsCheckBox(true)" toolTip="{allowEveryoneBtn.label}"/>
width="100%"
click="sendResponseToAllGuestsCheckBox(true, GuestPolicy.ALWAYS_ACCEPT)"
toolTip="{allowEveryoneBtn.label}"/>
</mx:VBox>
<mx:VBox width="100%" paddingTop="20" paddingBottom="20">
<mx:Button id="allowEveryoneBtn" styleName="mainActionButton"
label="{ResourceUtil.getInstance().getString('bbb.guests.allowEveryone.label')}"
width="100%" click="sendResponseToAllGuestsCheckBox(true)" toolTip="{allowEveryoneBtn.label}"/>
width="100%" click="sendResponseToAllGuestsCheckBox(true, GuestPolicy.ALWAYS_ACCEPT)"
toolTip="{allowEveryoneBtn.label}"/>
<mx:Button id="denyEveryoneBtn" styleName="mainActionButton"
label="{ResourceUtil.getInstance().getString('bbb.guests.denyEveryone.label')}"
width="100%" click="sendResponseToAllGuestsCheckBox(false)" toolTip="{denyEveryoneBtn.label}"/>
width="100%" click="sendResponseToAllGuestsCheckBox(false, GuestPolicy.ALWAYS_DENY)"
toolTip="{denyEveryoneBtn.label}"/>
</mx:VBox>
<mx:CheckBox id="rememberCheckBox" label="{ResourceUtil.getInstance().getString('bbb.guests.rememberAction.label')}"/>
<mx:CheckBox id="rememberCheckBox"
label="{ResourceUtil.getInstance().getString('bbb.guests.rememberAction.label')}"/>
</mx:VBox>
<mx:VRule height="100%"/>

View File

@ -892,11 +892,12 @@ package org.bigbluebutton.modules.users.services
}
public function handleGuestPolicyChanged(msg:Object):void {
var header: Object = msg.header as Object;
var body: Object = msg.body as Object;
var policy: String = body.policy as String;
LiveMeeting.inst().guestsWaiting.setGuestPolicy(policy);
LOGGER.debug("*** handleGuestPolicyChanged " + policy + " ****");
LiveMeeting.inst().guestsWaiting.setGuestPolicy(policy);
}
public function handleGetGuestPolicyReply(msg:Object):void {