add check for currentPresenter in pod message handlers

This commit is contained in:
Chad Pilkey 2017-12-15 19:47:06 -05:00
parent 2d72bba4c4
commit 32375f1c66
4 changed files with 16 additions and 6 deletions

View File

@ -25,6 +25,15 @@ object PresentationPodsApp {
state.presentationPodManager.getPod(podId)
}
def getPresentationPodIfPresenter(state: MeetingState2x, podId: String, userId: String): Option[PresentationPod] = {
for {
pod <- getPresentationPod(state, podId)
if pod.currentPresenter == userId
} yield {
pod
}
}
def getAllPresentationPodsInMeeting(state: MeetingState2x): Vector[PresentationPod] = {
state.presentationPodManager.getAllPresentationPodsInMeeting()
}

View File

@ -47,9 +47,8 @@ trait ResizeAndMovePagePubMsgHdlr extends RightsManagementTrait {
val heightRatio: Double = msg.body.heightRatio
val newState = for {
pod <- PresentationPodsApp.getPresentationPod(state, podId)
(updatedPod, page) <- pod.resizePage(presentationId, pageId,
xOffset, yOffset, widthRatio, heightRatio)
pod <- PresentationPodsApp.getPresentationPodIfPresenter(state, podId, msg.header.userId)
(updatedPod, page) <- pod.resizePage(presentationId, pageId, xOffset, yOffset, widthRatio, heightRatio)
} yield {
broadcastEvent(msg, podId, page)

View File

@ -42,7 +42,7 @@ trait SetCurrentPagePubMsgHdlr extends RightsManagementTrait {
val pageId = msg.body.pageId
val newState = for {
pod <- PresentationPodsApp.getPresentationPod(state, podId)
pod <- PresentationPodsApp.getPresentationPodIfPresenter(state, podId, userId)
updatedPod <- pod.setCurrentPage(presentationId, pageId)
} yield {

View File

@ -34,11 +34,13 @@ trait SetCurrentPresentationPubMsgHdlr extends RightsManagementTrait {
val podId = msg.body.podId
val presId = msg.body.presentationId
val userId = msg.header.userId
val newState = for {
updatedPod <- PresentationPodsApp.setCurrentPresentationInPod(state, podId, presId)
pod <- PresentationPodsApp.getPresentationPodIfPresenter(state, podId, userId)
updatedPod <- pod.setCurrentPresentation(presId)
} yield {
broadcastSetCurrentPresentationEvent(podId, msg.header.userId, presId)
broadcastSetCurrentPresentationEvent(podId, userId, presId)
val pods = state.presentationPodManager.addPod(updatedPod)
state.update(pods)