From ef1b00fe7f8e2ba9d1bb16baeaf6a31aa802a637 Mon Sep 17 00:00:00 2001 From: GuiLeme Date: Fri, 16 Jun 2023 12:22:14 -0300 Subject: [PATCH] [I-18101-back-end-tweak] - back-end portion - review changes --- .../apps/timer/CreateTimerReqMsgHdlr.scala | 11 ++------ .../timer/DeactivateTimerReqMsgHdlr.scala | 21 ++++++---------- .../apps/timer/ResetTimerReqMsgHdlr.scala | 21 +++++----------- .../core/apps/timer/SetTimerReqMsgHdlr.scala | 23 ++++++----------- .../core/apps/timer/SetTrackReqMsgHdlr.scala | 23 ++++++----------- .../apps/timer/StartTimerReqMsgHdlr.scala | 23 ++++++----------- .../core/apps/timer/StopTimerReqMsgHdlr.scala | 25 +++++++------------ .../apps/timer/SwitchTimerReqMsgHdlr.scala | 25 +++++++------------ 8 files changed, 55 insertions(+), 117 deletions(-) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/CreateTimerReqMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/CreateTimerReqMsgHdlr.scala index 725771c172..452b94e010 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/CreateTimerReqMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/CreateTimerReqMsgHdlr.scala @@ -9,14 +9,7 @@ trait CreateTimerPubMsgHdlr extends RightsManagementTrait { this: TimerApp2x => def handle(msg: CreateTimerPubMsg, liveMeeting: LiveMeeting, bus: MessageBus): Unit = { - val isTimerFeatureEnabled: Boolean = !liveMeeting.props.meetingProp.disabledFeatures.contains("timer") - - if (!isTimerFeatureEnabled) { - log.error("Timer feature is disabled for meeting {}, meetingId={}", liveMeeting.props.meetingProp.name, - liveMeeting.props.meetingProp.intId) - } else { - log.debug("Received CreateTimerPubMsg {}", CreateTimerPubMsg) - TimerModel.createTimer(liveMeeting.timerModel, msg.body.stopwatch, msg.body.time, msg.body.accumulated, msg.body.track) - } + log.debug("Received CreateTimerPubMsg {}", CreateTimerPubMsg) + TimerModel.createTimer(liveMeeting.timerModel, msg.body.stopwatch, msg.body.time, msg.body.accumulated, msg.body.track) } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/DeactivateTimerReqMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/DeactivateTimerReqMsgHdlr.scala index 889306ee43..65683cc174 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/DeactivateTimerReqMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/DeactivateTimerReqMsgHdlr.scala @@ -23,21 +23,14 @@ trait DeactivateTimerReqMsgHdlr extends RightsManagementTrait { bus.outGW.send(msgEvent) } - val isTimerFeatureEnabled: Boolean = !liveMeeting.props.meetingProp.disabledFeatures.contains("timer") - - if (!isTimerFeatureEnabled) { - log.error("Timer feature is disabled for meeting {}, meetingId={}", liveMeeting.props.meetingProp.name, - liveMeeting.props.meetingProp.intId) + if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && + permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { + val meetingId = liveMeeting.props.meetingProp.intId + val reason = "You need to be the presenter or moderator to deactivate timer" + PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) } else { - if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && - permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { - val meetingId = liveMeeting.props.meetingProp.intId - val reason = "You need to be the presenter or moderator to deactivate timer" - PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) - } else { - TimerModel.setIsActive(liveMeeting.timerModel, false); - broadcastEvent() - } + TimerModel.setIsActive(liveMeeting.timerModel, false); + broadcastEvent() } } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/ResetTimerReqMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/ResetTimerReqMsgHdlr.scala index 7e1a322210..d20701d3f9 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/ResetTimerReqMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/ResetTimerReqMsgHdlr.scala @@ -23,22 +23,13 @@ trait ResetTimerReqMsgHdlr extends RightsManagementTrait { bus.outGW.send(msgEvent) } - val isTimerFeatureEnabled: Boolean = !liveMeeting.props.meetingProp.disabledFeatures.contains("timer") - - if (!isTimerFeatureEnabled) { - log.error( - "Timer feature is disabled for meeting {}, meetingId={}", - liveMeeting.props.meetingProp.name, liveMeeting.props.meetingProp.intId - ) + if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && + permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { + val meetingId = liveMeeting.props.meetingProp.intId + val reason = "You need to be the presenter or moderator to reset timer" + PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) } else { - if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && - permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { - val meetingId = liveMeeting.props.meetingProp.intId - val reason = "You need to be the presenter or moderator to reset timer" - PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) - } else { - broadcastEvent() - } + broadcastEvent() } } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/SetTimerReqMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/SetTimerReqMsgHdlr.scala index 1907ab9b7e..c4bf82ef75 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/SetTimerReqMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/SetTimerReqMsgHdlr.scala @@ -25,23 +25,14 @@ trait SetTimerReqMsgHdlr extends RightsManagementTrait { bus.outGW.send(msgEvent) } - val isTimerFeatureEnabled: Boolean = !liveMeeting.props.meetingProp.disabledFeatures.contains("timer") - - if (!isTimerFeatureEnabled) { - log.error( - "Timer feature is disabled for meeting {}, meetingId={}", - liveMeeting.props.meetingProp.name, liveMeeting.props.meetingProp.intId - ) + if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && + permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { + val meetingId = liveMeeting.props.meetingProp.intId + val reason = "You need to be the presenter or moderator to set timer" + PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) } else { - if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && - permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { - val meetingId = liveMeeting.props.meetingProp.intId - val reason = "You need to be the presenter or moderator to set timer" - PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) - } else { - TimerModel.setTime(liveMeeting.timerModel, msg.body.time) - broadcastEvent(msg.body.time) - } + TimerModel.setTime(liveMeeting.timerModel, msg.body.time) + broadcastEvent(msg.body.time) } } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/SetTrackReqMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/SetTrackReqMsgHdlr.scala index 9355e6b884..bf2c50f6aa 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/SetTrackReqMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/SetTrackReqMsgHdlr.scala @@ -25,23 +25,14 @@ trait SetTrackReqMsgHdlr extends RightsManagementTrait { bus.outGW.send(msgEvent) } - val isTimerFeatureEnabled: Boolean = !liveMeeting.props.meetingProp.disabledFeatures.contains("timer") - - if (!isTimerFeatureEnabled) { - log.error( - "Timer feature is disabled for meeting {}, meetingId={}", - liveMeeting.props.meetingProp.name, liveMeeting.props.meetingProp.intId - ) + if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && + permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { + val meetingId = liveMeeting.props.meetingProp.intId + val reason = "You need to be the presenter or moderator to set track" + PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) } else { - if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && - permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { - val meetingId = liveMeeting.props.meetingProp.intId - val reason = "You need to be the presenter or moderator to set track" - PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) - } else { - TimerModel.setTrack(liveMeeting.timerModel, msg.body.track) - broadcastEvent(msg.body.track) - } + TimerModel.setTrack(liveMeeting.timerModel, msg.body.track) + broadcastEvent(msg.body.track) } } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/StartTimerReqMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/StartTimerReqMsgHdlr.scala index 816ef250b5..03bee1be3a 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/StartTimerReqMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/StartTimerReqMsgHdlr.scala @@ -23,22 +23,15 @@ trait StartTimerReqMsgHdlr extends RightsManagementTrait { bus.outGW.send(msgEvent) } - val isTimerFeatureEnabled: Boolean = !liveMeeting.props.meetingProp.disabledFeatures.contains("timer") - - if (!isTimerFeatureEnabled) { - log.error("Timer feature is disabled for meeting {}, meetingId={}", liveMeeting.props.meetingProp.name, - liveMeeting.props.meetingProp.intId) + if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && + permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { + val meetingId = liveMeeting.props.meetingProp.intId + val reason = "You need to be the presenter or moderator to start timer" + PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) } else { - if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && - permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { - val meetingId = liveMeeting.props.meetingProp.intId - val reason = "You need to be the presenter or moderator to start timer" - PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) - } else { - TimerModel.setStartedAt(liveMeeting.timerModel, System.currentTimeMillis()) - TimerModel.setRunning(liveMeeting.timerModel, true) - broadcastEvent() - } + TimerModel.setStartedAt(liveMeeting.timerModel, System.currentTimeMillis()) + TimerModel.setRunning(liveMeeting.timerModel, true) + broadcastEvent() } } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/StopTimerReqMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/StopTimerReqMsgHdlr.scala index 4da29b13e4..660b06339e 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/StopTimerReqMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/StopTimerReqMsgHdlr.scala @@ -25,23 +25,16 @@ trait StopTimerReqMsgHdlr extends RightsManagementTrait { bus.outGW.send(msgEvent) } - val isTimerFeatureEnabled: Boolean = !liveMeeting.props.meetingProp.disabledFeatures.contains("timer") - - if (!isTimerFeatureEnabled) { - log.error("Timer feature is disabled for meeting {}, meetingId={}", liveMeeting.props.meetingProp.name, - liveMeeting.props.meetingProp.intId) + if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && + permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId) && + msg.header.userId != "nodeJSapp") { + val meetingId = liveMeeting.props.meetingProp.intId + val reason = "You need to be the presenter or moderator to stop timer" + PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) } else { - if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && - permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId) && - msg.header.userId != "nodeJSapp") { - val meetingId = liveMeeting.props.meetingProp.intId - val reason = "You need to be the presenter or moderator to stop timer" - PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) - } else { - TimerModel.setAccumulated(liveMeeting.timerModel, msg.body.accumulated) - TimerModel.setRunning(liveMeeting.timerModel, false) - broadcastEvent(msg.body.accumulated) - } + TimerModel.setAccumulated(liveMeeting.timerModel, msg.body.accumulated) + TimerModel.setRunning(liveMeeting.timerModel, false) + broadcastEvent(msg.body.accumulated) } } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/SwitchTimerReqMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/SwitchTimerReqMsgHdlr.scala index bc4d3145ab..0e129c858d 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/SwitchTimerReqMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/timer/SwitchTimerReqMsgHdlr.scala @@ -25,24 +25,17 @@ trait SwitchTimerReqMsgHdlr extends RightsManagementTrait { bus.outGW.send(msgEvent) } - val isTimerFeatureEnabled: Boolean = !liveMeeting.props.meetingProp.disabledFeatures.contains("timer") - - if (!isTimerFeatureEnabled) { - log.error("Timer feature is disabled for meeting {}, meetingId={}", liveMeeting.props.meetingProp.name, - liveMeeting.props.meetingProp.intId) + if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && + permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { + val meetingId = liveMeeting.props.meetingProp.intId + val reason = "You need to be the presenter or moderator to switch timer" + PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) } else { - if (permissionFailed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId) && - permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) { - val meetingId = liveMeeting.props.meetingProp.intId - val reason = "You need to be the presenter or moderator to switch timer" - PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW, liveMeeting) + if (TimerModel.getStopwatch(liveMeeting.timerModel) != msg.body.stopwatch) { + TimerModel.setStopwatch(liveMeeting.timerModel, msg.body.stopwatch) + broadcastEvent(msg.body.stopwatch) } else { - if (TimerModel.getStopwatch(liveMeeting.timerModel) != msg.body.stopwatch) { - TimerModel.setStopwatch(liveMeeting.timerModel, msg.body.stopwatch) - broadcastEvent(msg.body.stopwatch) - } else { - log.debug("Timer is already in this stopwatch mode"); - } + log.debug("Timer is already in this stopwatch mode"); } } }