Merge pull request #4626 from ritzalam/appply-permissions-on-messages
Appply permissions on messages
This commit is contained in:
commit
bdd825ee97
@ -1,50 +1,59 @@
|
||||
package org.bigbluebutton.core.apps.presentationpod
|
||||
|
||||
import org.bigbluebutton.SystemConfiguration
|
||||
import org.bigbluebutton.common2.msgs._
|
||||
import org.bigbluebutton.core.apps.PermissionCheck
|
||||
import org.bigbluebutton.core.bus.MessageBus
|
||||
import org.bigbluebutton.core.domain.MeetingState2x
|
||||
import org.bigbluebutton.core.models.PresentationPod
|
||||
import org.bigbluebutton.core.running.LiveMeeting
|
||||
|
||||
trait CreateNewPresentationPodPubMsgHdlr {
|
||||
trait CreateNewPresentationPodPubMsgHdlr extends SystemConfiguration {
|
||||
this: PresentationPodHdlrs =>
|
||||
|
||||
def handle(msg: CreateNewPresentationPodPubMsg, state: MeetingState2x,
|
||||
liveMeeting: LiveMeeting, bus: MessageBus): MeetingState2x = {
|
||||
|
||||
def buildCreateNewPresentationPodEvtMsg(meetingId: String, ownerId: String, podId: String): BbbCommonEnvCoreMsg = {
|
||||
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, meetingId, ownerId)
|
||||
val envelope = BbbCoreEnvelope(CreateNewPresentationPodEvtMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(CreateNewPresentationPodEvtMsg.NAME, meetingId, ownerId)
|
||||
if (applyPermissionCheck && !PermissionCheck.isAllowed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId)) {
|
||||
val meetingId = liveMeeting.props.meetingProp.intId
|
||||
val reason = "No permission to eject user from meeting."
|
||||
PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW)
|
||||
state
|
||||
} else {
|
||||
def buildCreateNewPresentationPodEvtMsg(meetingId: String, ownerId: String, podId: String): BbbCommonEnvCoreMsg = {
|
||||
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, meetingId, ownerId)
|
||||
val envelope = BbbCoreEnvelope(CreateNewPresentationPodEvtMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(CreateNewPresentationPodEvtMsg.NAME, meetingId, ownerId)
|
||||
|
||||
val body = CreateNewPresentationPodEvtMsgBody(ownerId, podId)
|
||||
val event = CreateNewPresentationPodEvtMsg(header, body)
|
||||
val body = CreateNewPresentationPodEvtMsgBody(ownerId, podId)
|
||||
val event = CreateNewPresentationPodEvtMsg(header, body)
|
||||
|
||||
BbbCommonEnvCoreMsg(envelope, event)
|
||||
}
|
||||
BbbCommonEnvCoreMsg(envelope, event)
|
||||
}
|
||||
|
||||
val ownerId = msg.body.ownerId
|
||||
val ownerId = msg.body.ownerId
|
||||
|
||||
val resultPod: PresentationPod = PresentationPodsApp.getPresentationPod(state, "DEFAULT_PRESENTATION_POD") match {
|
||||
case None => PresentationPodsApp.createDefaultPresentationPod(ownerId)
|
||||
case Some(pod) => {
|
||||
if (pod.ownerId == "") {
|
||||
PresentationPodsApp.changeOwnershipOfDefaultPod(state, ownerId).get
|
||||
} else {
|
||||
PresentationPodsApp.createPresentationPod(ownerId)
|
||||
val resultPod: PresentationPod = PresentationPodsApp.getPresentationPod(state, "DEFAULT_PRESENTATION_POD") match {
|
||||
case None => PresentationPodsApp.createDefaultPresentationPod(ownerId)
|
||||
case Some(pod) => {
|
||||
if (pod.ownerId == "") {
|
||||
PresentationPodsApp.changeOwnershipOfDefaultPod(state, ownerId).get
|
||||
} else {
|
||||
PresentationPodsApp.createPresentationPod(ownerId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val respMsg = buildCreateNewPresentationPodEvtMsg(
|
||||
liveMeeting.props.meetingProp.intId,
|
||||
ownerId, resultPod.id
|
||||
)
|
||||
bus.outGW.send(respMsg)
|
||||
|
||||
val pods = state.presentationPodManager.addPod(resultPod)
|
||||
|
||||
state.update(pods)
|
||||
}
|
||||
|
||||
val respMsg = buildCreateNewPresentationPodEvtMsg(
|
||||
liveMeeting.props.meetingProp.intId,
|
||||
ownerId, resultPod.id
|
||||
)
|
||||
bus.outGW.send(respMsg)
|
||||
|
||||
val pods = state.presentationPodManager.addPod(resultPod)
|
||||
|
||||
state.update(pods)
|
||||
|
||||
}
|
||||
}
|
||||
|
43
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/GetAllPresentationPodsReqMsgHdlr.scala
Normal file → Executable file
43
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/GetAllPresentationPodsReqMsgHdlr.scala
Normal file → Executable file
@ -2,6 +2,7 @@ package org.bigbluebutton.core.apps.presentationpod
|
||||
|
||||
import org.bigbluebutton.common2.domain.{ PresentationPodVO, PresentationVO }
|
||||
import org.bigbluebutton.common2.msgs._
|
||||
import org.bigbluebutton.core.apps.PermissionCheck
|
||||
import org.bigbluebutton.core.bus.MessageBus
|
||||
import org.bigbluebutton.core.domain.MeetingState2x
|
||||
import org.bigbluebutton.core.models.PresentationPod
|
||||
@ -13,26 +14,34 @@ trait GetAllPresentationPodsReqMsgHdlr {
|
||||
def handle(msg: GetAllPresentationPodsReqMsg, state: MeetingState2x,
|
||||
liveMeeting: LiveMeeting, bus: MessageBus): MeetingState2x = {
|
||||
|
||||
def buildGetAllPresentationPodsRespMsg(pods: Vector[PresentationPodVO], requesterId: String): BbbCommonEnvCoreMsg = {
|
||||
val routing = Routing.addMsgToClientRouting(MessageTypes.DIRECT, liveMeeting.props.meetingProp.intId, requesterId)
|
||||
val envelope = BbbCoreEnvelope(GetAllPresentationPodsRespMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(GetAllPresentationPodsRespMsg.NAME, liveMeeting.props.meetingProp.intId, requesterId)
|
||||
if (applyPermissionCheck && !PermissionCheck.isAllowed(PermissionCheck.GUEST_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId)) {
|
||||
val meetingId = liveMeeting.props.meetingProp.intId
|
||||
val reason = "No permission to get all presentation pods from meeting."
|
||||
PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW)
|
||||
state
|
||||
} else {
|
||||
def buildGetAllPresentationPodsRespMsg(pods: Vector[PresentationPodVO], requesterId: String): BbbCommonEnvCoreMsg = {
|
||||
val routing = Routing.addMsgToClientRouting(MessageTypes.DIRECT, liveMeeting.props.meetingProp.intId, requesterId)
|
||||
val envelope = BbbCoreEnvelope(GetAllPresentationPodsRespMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(GetAllPresentationPodsRespMsg.NAME, liveMeeting.props.meetingProp.intId, requesterId)
|
||||
|
||||
val body = GetAllPresentationPodsRespMsgBody(pods)
|
||||
val event = GetAllPresentationPodsRespMsg(header, body)
|
||||
val body = GetAllPresentationPodsRespMsgBody(pods)
|
||||
val event = GetAllPresentationPodsRespMsg(header, body)
|
||||
|
||||
BbbCommonEnvCoreMsg(envelope, event)
|
||||
BbbCommonEnvCoreMsg(envelope, event)
|
||||
}
|
||||
|
||||
val requesterId = msg.body.requesterId
|
||||
|
||||
val pods = PresentationPodsApp.getAllPresentationPodsInMeeting(state)
|
||||
|
||||
val podsVO = pods.map(pod => PresentationPodsApp.translatePresentationPodToVO(pod))
|
||||
val event = buildGetAllPresentationPodsRespMsg(podsVO, requesterId)
|
||||
|
||||
bus.outGW.send(event)
|
||||
|
||||
state
|
||||
}
|
||||
|
||||
val requesterId = msg.body.requesterId
|
||||
|
||||
val pods = PresentationPodsApp.getAllPresentationPodsInMeeting(state)
|
||||
|
||||
val podsVO = pods.map(pod => PresentationPodsApp.translatePresentationPodToVO(pod))
|
||||
val event = buildGetAllPresentationPodsRespMsg(podsVO, requesterId)
|
||||
|
||||
bus.outGW.send(event)
|
||||
|
||||
state
|
||||
}
|
||||
}
|
||||
|
59
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/GetPresentationInfoReqMsgHdlr.scala
Normal file → Executable file
59
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/GetPresentationInfoReqMsgHdlr.scala
Normal file → Executable file
@ -2,6 +2,7 @@ package org.bigbluebutton.core.apps.presentationpod
|
||||
|
||||
import org.bigbluebutton.common2.domain.PresentationVO
|
||||
import org.bigbluebutton.common2.msgs._
|
||||
import org.bigbluebutton.core.apps.PermissionCheck
|
||||
import org.bigbluebutton.core.bus.MessageBus
|
||||
import org.bigbluebutton.core.domain.MeetingState2x
|
||||
import org.bigbluebutton.core.running.LiveMeeting
|
||||
@ -12,34 +13,42 @@ trait GetPresentationInfoReqMsgHdlr {
|
||||
def handle(msg: GetPresentationInfoReqMsg, state: MeetingState2x,
|
||||
liveMeeting: LiveMeeting, bus: MessageBus): MeetingState2x = {
|
||||
|
||||
def buildGetPresentationInfoRespMsg(presentations: Vector[PresentationVO], podId: String,
|
||||
requesterId: String): BbbCommonEnvCoreMsg = {
|
||||
val routing = Routing.addMsgToClientRouting(MessageTypes.DIRECT, liveMeeting.props.meetingProp.intId, requesterId)
|
||||
val envelope = BbbCoreEnvelope(GetPresentationInfoRespMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(GetPresentationInfoRespMsg.NAME, liveMeeting.props.meetingProp.intId, requesterId)
|
||||
if (applyPermissionCheck && !PermissionCheck.isAllowed(PermissionCheck.GUEST_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId)) {
|
||||
val meetingId = liveMeeting.props.meetingProp.intId
|
||||
val reason = "No permission get presentation info from meeting."
|
||||
PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW)
|
||||
state
|
||||
} else {
|
||||
def buildGetPresentationInfoRespMsg(presentations: Vector[PresentationVO], podId: String,
|
||||
requesterId: String): BbbCommonEnvCoreMsg = {
|
||||
val routing = Routing.addMsgToClientRouting(MessageTypes.DIRECT, liveMeeting.props.meetingProp.intId, requesterId)
|
||||
val envelope = BbbCoreEnvelope(GetPresentationInfoRespMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(GetPresentationInfoRespMsg.NAME, liveMeeting.props.meetingProp.intId, requesterId)
|
||||
|
||||
val body = GetPresentationInfoRespMsgBody(podId, presentations)
|
||||
val event = GetPresentationInfoRespMsg(header, body)
|
||||
val body = GetPresentationInfoRespMsgBody(podId, presentations)
|
||||
val event = GetPresentationInfoRespMsg(header, body)
|
||||
|
||||
BbbCommonEnvCoreMsg(envelope, event)
|
||||
BbbCommonEnvCoreMsg(envelope, event)
|
||||
}
|
||||
|
||||
val requesterId = msg.body.userId
|
||||
val podId = msg.body.podId
|
||||
|
||||
for {
|
||||
pod <- PresentationPodsApp.getPresentationPod(state, podId)
|
||||
} yield {
|
||||
val presInPod = pod.presentations
|
||||
|
||||
val presVOs = presInPod.values.map { p =>
|
||||
PresentationVO(p.id, p.name, p.current, p.pages.values.toVector, p.downloadable)
|
||||
}.toVector
|
||||
val event = buildGetPresentationInfoRespMsg(presVOs, podId, requesterId)
|
||||
|
||||
bus.outGW.send(event)
|
||||
|
||||
}
|
||||
state
|
||||
}
|
||||
|
||||
val requesterId = msg.body.userId
|
||||
val podId = msg.body.podId
|
||||
|
||||
for {
|
||||
pod <- PresentationPodsApp.getPresentationPod(state, podId)
|
||||
} yield {
|
||||
val presInPod = pod.presentations
|
||||
|
||||
val presVOs = presInPod.values.map { p =>
|
||||
PresentationVO(p.id, p.name, p.current, p.pages.values.toVector, p.downloadable)
|
||||
}.toVector
|
||||
val event = buildGetPresentationInfoRespMsg(presVOs, podId, requesterId)
|
||||
|
||||
bus.outGW.send(event)
|
||||
|
||||
}
|
||||
state
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.bigbluebutton.core.apps.presentationpod
|
||||
|
||||
import org.bigbluebutton.common2.msgs._
|
||||
import org.bigbluebutton.core.apps.PermissionCheck
|
||||
import org.bigbluebutton.core.bus.MessageBus
|
||||
import org.bigbluebutton.core.domain.MeetingState2x
|
||||
import org.bigbluebutton.core.running.LiveMeeting
|
||||
@ -11,54 +12,61 @@ trait RemovePresentationPodPubMsgHdlr {
|
||||
def handle(msg: RemovePresentationPodPubMsg, state: MeetingState2x,
|
||||
liveMeeting: LiveMeeting, bus: MessageBus): MeetingState2x = {
|
||||
|
||||
def buildRemovePresentationPodEvtMsg(meetingId: String, ownerId: String, podId: String): BbbCommonEnvCoreMsg = {
|
||||
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, meetingId, ownerId)
|
||||
val envelope = BbbCoreEnvelope(RemovePresentationPodEvtMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(RemovePresentationPodEvtMsg.NAME, meetingId, ownerId)
|
||||
if (applyPermissionCheck && !PermissionCheck.isAllowed(PermissionCheck.MOD_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) {
|
||||
val meetingId = liveMeeting.props.meetingProp.intId
|
||||
val reason = "No permission to remove presentation pod from meeting."
|
||||
PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW)
|
||||
state
|
||||
} else {
|
||||
def buildRemovePresentationPodEvtMsg(meetingId: String, ownerId: String, podId: String): BbbCommonEnvCoreMsg = {
|
||||
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, meetingId, ownerId)
|
||||
val envelope = BbbCoreEnvelope(RemovePresentationPodEvtMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(RemovePresentationPodEvtMsg.NAME, meetingId, ownerId)
|
||||
|
||||
val body = RemovePresentationPodEvtMsgBody(ownerId, podId)
|
||||
val event = RemovePresentationPodEvtMsg(header, body)
|
||||
val body = RemovePresentationPodEvtMsgBody(ownerId, podId)
|
||||
val event = RemovePresentationPodEvtMsg(header, body)
|
||||
|
||||
BbbCommonEnvCoreMsg(envelope, event)
|
||||
BbbCommonEnvCoreMsg(envelope, event)
|
||||
}
|
||||
|
||||
val requesterId = msg.body.requesterId // TODO -- use it
|
||||
|
||||
val newState = for {
|
||||
pod <- PresentationPodsApp.getPresentationPod(state, msg.body.podId)
|
||||
} yield {
|
||||
|
||||
val ownerId = pod.ownerId
|
||||
|
||||
val event = buildRemovePresentationPodEvtMsg(
|
||||
liveMeeting.props.meetingProp.intId,
|
||||
ownerId, pod.id
|
||||
)
|
||||
|
||||
bus.outGW.send(event)
|
||||
|
||||
val pods = state.presentationPodManager.removePod(pod.id)
|
||||
state.update(pods)
|
||||
}
|
||||
|
||||
newState match {
|
||||
case Some(ns) => ns
|
||||
case None => state
|
||||
}
|
||||
|
||||
// TODO check if requesterId == ownerId
|
||||
// TODO check about notifying only the list of authorized?
|
||||
|
||||
// val respMsg = buildRemovePresentationPodEvtMsg(
|
||||
// liveMeeting.props.meetingProp.intId,
|
||||
// ownerId, pod.id
|
||||
// )
|
||||
// bus.outGW.send(respMsg)
|
||||
//
|
||||
// log.warning("RemovePresentationPodPubMsgHdlr new podId=" + pod.id)
|
||||
//
|
||||
// val pods = state.presentationPodManager.removePod(pod)
|
||||
// state.update(pods)
|
||||
}
|
||||
|
||||
val requesterId = msg.body.requesterId // TODO -- use it
|
||||
|
||||
val newState = for {
|
||||
pod <- PresentationPodsApp.getPresentationPod(state, msg.body.podId)
|
||||
} yield {
|
||||
|
||||
val ownerId = pod.ownerId
|
||||
|
||||
val event = buildRemovePresentationPodEvtMsg(
|
||||
liveMeeting.props.meetingProp.intId,
|
||||
ownerId, pod.id
|
||||
)
|
||||
|
||||
bus.outGW.send(event)
|
||||
|
||||
val pods = state.presentationPodManager.removePod(pod.id)
|
||||
state.update(pods)
|
||||
}
|
||||
|
||||
newState match {
|
||||
case Some(ns) => ns
|
||||
case None => state
|
||||
}
|
||||
|
||||
// TODO check if requesterId == ownerId
|
||||
// TODO check about notifying only the list of authorized?
|
||||
|
||||
// val respMsg = buildRemovePresentationPodEvtMsg(
|
||||
// liveMeeting.props.meetingProp.intId,
|
||||
// ownerId, pod.id
|
||||
// )
|
||||
// bus.outGW.send(respMsg)
|
||||
//
|
||||
// log.warning("RemovePresentationPodPubMsgHdlr new podId=" + pod.id)
|
||||
//
|
||||
// val pods = state.presentationPodManager.removePod(pod)
|
||||
// state.update(pods)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.bigbluebutton.core.apps.presentationpod
|
||||
|
||||
import org.bigbluebutton.common2.msgs._
|
||||
import org.bigbluebutton.core.apps.PermissionCheck
|
||||
import org.bigbluebutton.core.bus.MessageBus
|
||||
import org.bigbluebutton.core.domain.MeetingState2x
|
||||
import org.bigbluebutton.core.running.LiveMeeting
|
||||
@ -13,35 +14,42 @@ trait RemovePresentationPubMsgHdlr {
|
||||
liveMeeting: LiveMeeting, bus: MessageBus
|
||||
): MeetingState2x = {
|
||||
|
||||
def broadcastRemovePresentationEvtMsg(podId: String, userId: String, presentationId: String): Unit = {
|
||||
val routing = Routing.addMsgToClientRouting(
|
||||
MessageTypes.BROADCAST_TO_MEETING,
|
||||
liveMeeting.props.meetingProp.intId, userId
|
||||
)
|
||||
val envelope = BbbCoreEnvelope(RemovePresentationEvtMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(RemovePresentationEvtMsg.NAME, liveMeeting.props.meetingProp.intId, userId)
|
||||
if (applyPermissionCheck && !PermissionCheck.isAllowed(PermissionCheck.MOD_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) {
|
||||
val meetingId = liveMeeting.props.meetingProp.intId
|
||||
val reason = "No permission to remove presentation from meeting."
|
||||
PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW)
|
||||
state
|
||||
} else {
|
||||
def broadcastRemovePresentationEvtMsg(podId: String, userId: String, presentationId: String): Unit = {
|
||||
val routing = Routing.addMsgToClientRouting(
|
||||
MessageTypes.BROADCAST_TO_MEETING,
|
||||
liveMeeting.props.meetingProp.intId, userId
|
||||
)
|
||||
val envelope = BbbCoreEnvelope(RemovePresentationEvtMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(RemovePresentationEvtMsg.NAME, liveMeeting.props.meetingProp.intId, userId)
|
||||
|
||||
val body = RemovePresentationEvtMsgBody(podId, presentationId)
|
||||
val event = RemovePresentationEvtMsg(header, body)
|
||||
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
|
||||
bus.outGW.send(msgEvent)
|
||||
}
|
||||
val body = RemovePresentationEvtMsgBody(podId, presentationId)
|
||||
val event = RemovePresentationEvtMsg(header, body)
|
||||
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
|
||||
bus.outGW.send(msgEvent)
|
||||
}
|
||||
|
||||
val podId = msg.body.podId
|
||||
val presentationId = msg.body.presentationId
|
||||
val podId = msg.body.podId
|
||||
val presentationId = msg.body.presentationId
|
||||
|
||||
val newState = for {
|
||||
pod <- PresentationPodsApp.getPresentationPod(state, podId)
|
||||
} yield {
|
||||
broadcastRemovePresentationEvtMsg(pod.id, msg.header.userId, presentationId)
|
||||
val newState = for {
|
||||
pod <- PresentationPodsApp.getPresentationPod(state, podId)
|
||||
} yield {
|
||||
broadcastRemovePresentationEvtMsg(pod.id, msg.header.userId, presentationId)
|
||||
|
||||
val pods = state.presentationPodManager.removePresentationInPod(pod.id, presentationId)
|
||||
state.update(pods)
|
||||
}
|
||||
val pods = state.presentationPodManager.removePresentationInPod(pod.id, presentationId)
|
||||
state.update(pods)
|
||||
}
|
||||
|
||||
newState match {
|
||||
case Some(ns) => ns
|
||||
case None => state
|
||||
newState match {
|
||||
case Some(ns) => ns
|
||||
case None => state
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
71
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetCurrentPagePubMsgHdlr.scala
Normal file → Executable file
71
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetCurrentPagePubMsgHdlr.scala
Normal file → Executable file
@ -1,6 +1,7 @@
|
||||
package org.bigbluebutton.core.apps.presentationpod
|
||||
|
||||
import org.bigbluebutton.common2.msgs._
|
||||
import org.bigbluebutton.core.apps.PermissionCheck
|
||||
import org.bigbluebutton.core.bus.MessageBus
|
||||
import org.bigbluebutton.core.domain.MeetingState2x
|
||||
import org.bigbluebutton.core.running.LiveMeeting
|
||||
@ -15,44 +16,52 @@ trait SetCurrentPagePubMsgHdlr {
|
||||
liveMeeting: LiveMeeting, bus: MessageBus
|
||||
): MeetingState2x = {
|
||||
|
||||
def broadcastSetCurrentPageEvtMsg(podId: String, presentationId: String, pageId: String, userId: String): Unit = {
|
||||
val routing = Routing.addMsgToClientRouting(
|
||||
MessageTypes.BROADCAST_TO_MEETING,
|
||||
liveMeeting.props.meetingProp.intId, userId
|
||||
)
|
||||
val envelope = BbbCoreEnvelope(SetCurrentPageEvtMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(SetCurrentPageEvtMsg.NAME, liveMeeting.props.meetingProp.intId, userId)
|
||||
if (applyPermissionCheck && !PermissionCheck.isAllowed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) {
|
||||
val meetingId = liveMeeting.props.meetingProp.intId
|
||||
val reason = "No permission to set presentation page."
|
||||
PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW)
|
||||
state
|
||||
} else {
|
||||
def broadcastSetCurrentPageEvtMsg(podId: String, presentationId: String, pageId: String, userId: String): Unit = {
|
||||
val routing = Routing.addMsgToClientRouting(
|
||||
MessageTypes.BROADCAST_TO_MEETING,
|
||||
liveMeeting.props.meetingProp.intId, userId
|
||||
)
|
||||
val envelope = BbbCoreEnvelope(SetCurrentPageEvtMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(SetCurrentPageEvtMsg.NAME, liveMeeting.props.meetingProp.intId, userId)
|
||||
|
||||
val body = SetCurrentPageEvtMsgBody(podId, presentationId, pageId)
|
||||
val event = SetCurrentPageEvtMsg(header, body)
|
||||
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
|
||||
bus.outGW.send(msgEvent)
|
||||
}
|
||||
val body = SetCurrentPageEvtMsgBody(podId, presentationId, pageId)
|
||||
val event = SetCurrentPageEvtMsg(header, body)
|
||||
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
|
||||
bus.outGW.send(msgEvent)
|
||||
}
|
||||
|
||||
val podId = msg.body.podId
|
||||
val userId = msg.header.userId
|
||||
val presentationId = msg.body.presentationId
|
||||
val pageId = msg.body.pageId
|
||||
val podId = msg.body.podId
|
||||
val userId = msg.header.userId
|
||||
val presentationId = msg.body.presentationId
|
||||
val pageId = msg.body.pageId
|
||||
|
||||
val newState = for {
|
||||
pod <- PresentationPodsApp.getPresentationPod(state, podId)
|
||||
presentationToModify <- pod.getPresentation(presentationId)
|
||||
updatedPod <- pod.setCurrentPage(presentationId, pageId)
|
||||
} yield {
|
||||
val newState = for {
|
||||
pod <- PresentationPodsApp.getPresentationPod(state, podId)
|
||||
presentationToModify <- pod.getPresentation(presentationId)
|
||||
updatedPod <- pod.setCurrentPage(presentationId, pageId)
|
||||
} yield {
|
||||
|
||||
if (Users2x.userIsInPresenterGroup(liveMeeting.users2x, userId) || userId.equals(pod.ownerId)) {
|
||||
broadcastSetCurrentPageEvtMsg(pod.id, presentationId, pageId, userId)
|
||||
if (Users2x.userIsInPresenterGroup(liveMeeting.users2x, userId) || userId.equals(pod.ownerId)) {
|
||||
broadcastSetCurrentPageEvtMsg(pod.id, presentationId, pageId, userId)
|
||||
|
||||
val pods = state.presentationPodManager.addPod(updatedPod)
|
||||
state.update(pods)
|
||||
} else {
|
||||
state
|
||||
val pods = state.presentationPodManager.addPod(updatedPod)
|
||||
state.update(pods)
|
||||
} else {
|
||||
state
|
||||
}
|
||||
}
|
||||
|
||||
newState match {
|
||||
case Some(ns) => ns
|
||||
case None => state
|
||||
}
|
||||
}
|
||||
|
||||
newState match {
|
||||
case Some(ns) => ns
|
||||
case None => state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.bigbluebutton.core.apps.presentationpod
|
||||
|
||||
import org.bigbluebutton.common2.msgs._
|
||||
import org.bigbluebutton.core.apps.PermissionCheck
|
||||
import org.bigbluebutton.core.bus.MessageBus
|
||||
import org.bigbluebutton.core.domain.MeetingState2x
|
||||
import org.bigbluebutton.core.running.LiveMeeting
|
||||
@ -13,32 +14,39 @@ trait SetCurrentPresentationPubMsgHdlr {
|
||||
liveMeeting: LiveMeeting, bus: MessageBus
|
||||
): MeetingState2x = {
|
||||
|
||||
def broadcastSetCurrentPresentationEvent(podId: String, userId: String, presentationId: String): Unit = {
|
||||
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, liveMeeting.props.meetingProp.intId, userId)
|
||||
val envelope = BbbCoreEnvelope(SetCurrentPresentationEvtMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(SetCurrentPresentationEvtMsg.NAME, liveMeeting.props.meetingProp.intId, userId)
|
||||
if (applyPermissionCheck && !PermissionCheck.isAllowed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId)) {
|
||||
val meetingId = liveMeeting.props.meetingProp.intId
|
||||
val reason = "No permission to set presentation page."
|
||||
PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW)
|
||||
state
|
||||
} else {
|
||||
def broadcastSetCurrentPresentationEvent(podId: String, userId: String, presentationId: String): Unit = {
|
||||
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, liveMeeting.props.meetingProp.intId, userId)
|
||||
val envelope = BbbCoreEnvelope(SetCurrentPresentationEvtMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(SetCurrentPresentationEvtMsg.NAME, liveMeeting.props.meetingProp.intId, userId)
|
||||
|
||||
val body = SetCurrentPresentationEvtMsgBody(podId, presentationId)
|
||||
val event = SetCurrentPresentationEvtMsg(header, body)
|
||||
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
|
||||
bus.outGW.send(msgEvent)
|
||||
}
|
||||
val body = SetCurrentPresentationEvtMsgBody(podId, presentationId)
|
||||
val event = SetCurrentPresentationEvtMsg(header, body)
|
||||
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
|
||||
bus.outGW.send(msgEvent)
|
||||
}
|
||||
|
||||
val podId = msg.body.podId
|
||||
val presId = msg.body.presentationId
|
||||
val podId = msg.body.podId
|
||||
val presId = msg.body.presentationId
|
||||
|
||||
val newState = for {
|
||||
updatedPod <- PresentationPodsApp.setCurrentPresentationInPod(state, podId, presId)
|
||||
} yield {
|
||||
broadcastSetCurrentPresentationEvent(podId, msg.header.userId, presId)
|
||||
val newState = for {
|
||||
updatedPod <- PresentationPodsApp.setCurrentPresentationInPod(state, podId, presId)
|
||||
} yield {
|
||||
broadcastSetCurrentPresentationEvent(podId, msg.header.userId, presId)
|
||||
|
||||
val pods = state.presentationPodManager.addPod(updatedPod)
|
||||
state.update(pods)
|
||||
}
|
||||
val pods = state.presentationPodManager.addPod(updatedPod)
|
||||
state.update(pods)
|
||||
}
|
||||
|
||||
newState match {
|
||||
case Some(ns) => ns
|
||||
case None => state
|
||||
newState match {
|
||||
case Some(ns) => ns
|
||||
case None => state
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
69
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetPresenterInPodReqMsgHdlr.scala
Normal file → Executable file
69
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/presentationpod/SetPresenterInPodReqMsgHdlr.scala
Normal file → Executable file
@ -1,6 +1,7 @@
|
||||
package org.bigbluebutton.core.apps.presentationpod
|
||||
|
||||
import org.bigbluebutton.common2.msgs._
|
||||
import org.bigbluebutton.core.apps.PermissionCheck
|
||||
import org.bigbluebutton.core.bus.MessageBus
|
||||
import org.bigbluebutton.core.domain.MeetingState2x
|
||||
import org.bigbluebutton.core.running.LiveMeeting
|
||||
@ -14,44 +15,52 @@ trait SetPresenterInPodReqMsgHdlr {
|
||||
liveMeeting: LiveMeeting, bus: MessageBus
|
||||
): MeetingState2x = {
|
||||
|
||||
def broadcastSetPresenterInPodRespMsg(podId: String, prevPresenterId: String, nextPresenterId: String, requesterId: String): Unit = {
|
||||
val routing = Routing.addMsgToClientRouting(
|
||||
MessageTypes.BROADCAST_TO_MEETING,
|
||||
liveMeeting.props.meetingProp.intId, requesterId
|
||||
)
|
||||
val envelope = BbbCoreEnvelope(SetPresenterInPodRespMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(SetPresenterInPodRespMsg.NAME, liveMeeting.props.meetingProp.intId, requesterId)
|
||||
if (applyPermissionCheck && !PermissionCheck.isAllowed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId)) {
|
||||
val meetingId = liveMeeting.props.meetingProp.intId
|
||||
val reason = "No permission to set presenter in presentation."
|
||||
PermissionCheck.ejectUserForFailedPermission(meetingId, msg.header.userId, reason, bus.outGW)
|
||||
state
|
||||
} else {
|
||||
def broadcastSetPresenterInPodRespMsg(podId: String, prevPresenterId: String, nextPresenterId: String, requesterId: String): Unit = {
|
||||
val routing = Routing.addMsgToClientRouting(
|
||||
MessageTypes.BROADCAST_TO_MEETING,
|
||||
liveMeeting.props.meetingProp.intId, requesterId
|
||||
)
|
||||
val envelope = BbbCoreEnvelope(SetPresenterInPodRespMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(SetPresenterInPodRespMsg.NAME, liveMeeting.props.meetingProp.intId, requesterId)
|
||||
|
||||
val body = SetPresenterInPodRespMsgBody(podId, prevPresenterId, nextPresenterId)
|
||||
val event = SetPresenterInPodRespMsg(header, body)
|
||||
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
|
||||
bus.outGW.send(msgEvent)
|
||||
}
|
||||
val body = SetPresenterInPodRespMsgBody(podId, prevPresenterId, nextPresenterId)
|
||||
val event = SetPresenterInPodRespMsg(header, body)
|
||||
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
|
||||
bus.outGW.send(msgEvent)
|
||||
}
|
||||
|
||||
val podId: String = msg.body.podId
|
||||
val requesterId: String = msg.header.userId
|
||||
val nextPresenterId: String = msg.body.nextPresenterId
|
||||
val prevPresenterId: String = msg.body.prevPresenterId
|
||||
val podId: String = msg.body.podId
|
||||
val requesterId: String = msg.header.userId
|
||||
val nextPresenterId: String = msg.body.nextPresenterId
|
||||
val prevPresenterId: String = msg.body.prevPresenterId
|
||||
|
||||
val newState = for {
|
||||
pod <- PresentationPodsApp.getPresentationPod(state, podId)
|
||||
} yield {
|
||||
val newState = for {
|
||||
pod <- PresentationPodsApp.getPresentationPod(state, podId)
|
||||
} yield {
|
||||
|
||||
if (Users2x.userIsInPresenterGroup(liveMeeting.users2x, requesterId) || requesterId.equals(pod.ownerId)) {
|
||||
val updatedPod = pod.setCurrentPresenter(nextPresenterId)
|
||||
if (Users2x.userIsInPresenterGroup(liveMeeting.users2x, requesterId) || requesterId.equals(pod.ownerId)) {
|
||||
val updatedPod = pod.setCurrentPresenter(nextPresenterId)
|
||||
|
||||
broadcastSetPresenterInPodRespMsg(pod.id, prevPresenterId, nextPresenterId, requesterId)
|
||||
broadcastSetPresenterInPodRespMsg(pod.id, prevPresenterId, nextPresenterId, requesterId)
|
||||
|
||||
val pods = state.presentationPodManager.addPod(updatedPod)
|
||||
state.update(pods)
|
||||
} else {
|
||||
state
|
||||
val pods = state.presentationPodManager.addPod(updatedPod)
|
||||
state.update(pods)
|
||||
} else {
|
||||
state
|
||||
}
|
||||
}
|
||||
|
||||
newState match {
|
||||
case Some(ns) => ns
|
||||
case None => state
|
||||
}
|
||||
}
|
||||
|
||||
newState match {
|
||||
case Some(ns) => ns
|
||||
case None => state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,17 +13,6 @@ trait AddUserToPresenterGroupCmdMsgHdlr {
|
||||
|
||||
def handleAddUserToPresenterGroupCmdMsg(msg: AddUserToPresenterGroupCmdMsg) {
|
||||
|
||||
def broadcastAddUserToPresenterGroup(meetingId: String, userId: String, requesterId: String): Unit = {
|
||||
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, meetingId, userId)
|
||||
val envelope = BbbCoreEnvelope(UserAddedToPresenterGroupEvtMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(UserAddedToPresenterGroupEvtMsg.NAME, meetingId, userId)
|
||||
val body = UserAddedToPresenterGroupEvtMsgBody(userId, requesterId)
|
||||
val event = UserAddedToPresenterGroupEvtMsg(header, body)
|
||||
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
|
||||
|
||||
outGW.send(msgEvent)
|
||||
}
|
||||
|
||||
if (applyPermissionCheck && !PermissionCheck.isAllowed(PermissionCheck.MOD_LEVEL, PermissionCheck.VIEWER_LEVEL, liveMeeting.users2x, msg.header.userId)) {
|
||||
val meetingId = liveMeeting.props.meetingProp.intId
|
||||
val reason = "No permission to add user to presenter group."
|
||||
@ -36,8 +25,7 @@ trait AddUserToPresenterGroupCmdMsgHdlr {
|
||||
requester <- Users2x.findWithIntId(liveMeeting.users2x, requesterId)
|
||||
} yield {
|
||||
if (requester.role == Roles.MODERATOR_ROLE) {
|
||||
Users2x.addUserToPresenterGroup(liveMeeting.users2x, userId)
|
||||
broadcastAddUserToPresenterGroup(liveMeeting.props.meetingProp.intId, userId, requesterId)
|
||||
UsersApp.addUserToPresenterGroup(liveMeeting, outGW, userId, requesterId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,35 @@ package org.bigbluebutton.core.apps.users
|
||||
|
||||
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.running.{ LiveMeeting, OutMsgRouter }
|
||||
|
||||
object UsersApp {
|
||||
def broadcastAddUserToPresenterGroup(meetingId: String, userId: String, requesterId: String,
|
||||
outGW: OutMsgRouter): Unit = {
|
||||
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, meetingId, userId)
|
||||
val envelope = BbbCoreEnvelope(UserAddedToPresenterGroupEvtMsg.NAME, routing)
|
||||
val header = BbbClientMsgHeader(UserAddedToPresenterGroupEvtMsg.NAME, meetingId, userId)
|
||||
val body = UserAddedToPresenterGroupEvtMsgBody(userId, requesterId)
|
||||
val event = UserAddedToPresenterGroupEvtMsg(header, body)
|
||||
val msgEvent = BbbCommonEnvCoreMsg(envelope, event)
|
||||
|
||||
outGW.send(msgEvent)
|
||||
}
|
||||
|
||||
def addUserToPresenterGroup(liveMeeting: LiveMeeting, outGW: OutMsgRouter,
|
||||
userId: String, requesterId: String): Unit = {
|
||||
Users2x.addUserToPresenterGroup(liveMeeting.users2x, userId)
|
||||
UsersApp.broadcastAddUserToPresenterGroup(
|
||||
liveMeeting.props.meetingProp.intId,
|
||||
userId, requesterId, outGW
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UsersApp(
|
||||
val liveMeeting: LiveMeeting,
|
||||
val outGW: OutMsgRouter,
|
||||
|
@ -3,6 +3,7 @@ package org.bigbluebutton.core.running
|
||||
import org.bigbluebutton.SystemConfiguration
|
||||
import org.bigbluebutton.common2.msgs._
|
||||
import org.bigbluebutton.core.api.{ BreakoutRoomEndedInternalMsg, DestroyMeetingInternalMsg, EndBreakoutRoomInternalMsg }
|
||||
import org.bigbluebutton.core.apps.users.UsersApp
|
||||
import org.bigbluebutton.core.bus.{ BigBlueButtonEvent, InternalEventBus }
|
||||
import org.bigbluebutton.core.domain.MeetingState2x
|
||||
import org.bigbluebutton.core.models._
|
||||
@ -54,6 +55,11 @@ trait HandlerHelpers extends SystemConfiguration {
|
||||
if (!Users2x.hasPresenter(liveMeeting.users2x)) {
|
||||
automaticallyAssignPresenter(outGW, liveMeeting)
|
||||
}
|
||||
|
||||
if (newUser.role == Roles.MODERATOR_ROLE) {
|
||||
UsersApp.addUserToPresenterGroup(liveMeeting, outGW, newUser.intId, newUser.intId)
|
||||
}
|
||||
|
||||
state.update(state.expiryTracker.setUserHasJoined())
|
||||
case None =>
|
||||
state
|
||||
|
Loading…
Reference in New Issue
Block a user