Merge pull request #18877 from gustavotrott/graphql-pres-props

graphql-server: Add new columns to presentation
This commit is contained in:
Gustavo Trott 2023-09-29 14:35:32 -03:00 committed by GitHub
commit 45224c0758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 62 additions and 7 deletions

View File

@ -6,7 +6,7 @@ import org.bigbluebutton.core.apps.groupchats.GroupChatApp
import org.bigbluebutton.core.apps.{ PermissionCheck, RightsManagementTrait }
import org.bigbluebutton.core.apps.presentationpod.PresentationSender
import org.bigbluebutton.core.bus.MessageBus
import org.bigbluebutton.core.db.ChatMessageDAO
import org.bigbluebutton.core.db.{ ChatMessageDAO, PresPresentationDAO }
import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.running.LiveMeeting
import org.bigbluebutton.core.util.RandomStringGenerator
@ -53,12 +53,13 @@ trait MakePresentationDownloadReqMsgHdlr extends RightsManagementTrait {
def buildBroadcastNewPresFileAvailable(newPresFileAvailableMsg: NewPresFileAvailableMsg, liveMeeting: LiveMeeting): BbbCommonEnvCoreMsg = {
val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, liveMeeting.props.meetingProp.intId, "not-used")
val envelope = BbbCoreEnvelope(PresentationPageConvertedEventMsg.NAME, routing)
val envelope = BbbCoreEnvelope(NewPresFileAvailableEvtMsg.NAME, routing)
val header = BbbClientMsgHeader(NewPresFileAvailableEvtMsg.NAME, liveMeeting.props.meetingProp.intId, "not-used")
val body = NewPresFileAvailableEvtMsgBody(
annotatedFileURI = newPresFileAvailableMsg.body.annotatedFileURI,
originalFileURI = newPresFileAvailableMsg.body.originalFileURI,
convertedFileURI = newPresFileAvailableMsg.body.convertedFileURI, presId = newPresFileAvailableMsg.body.presId,
convertedFileURI = newPresFileAvailableMsg.body.convertedFileURI,
presId = newPresFileAvailableMsg.body.presId,
fileStateType = newPresFileAvailableMsg.body.fileStateType
)
val event = NewPresFileAvailableEvtMsg(header, body)
@ -224,7 +225,7 @@ trait MakePresentationDownloadReqMsgHdlr extends RightsManagementTrait {
val currentPage: PresentationPage = PresentationInPod.getCurrentPage(currentPres.get).get
val pagesRange: List[Int] = if (allPages) (1 to pageCount).toList else List(currentPage.num)
val exportJob: ExportJob = new ExportJob(jobId, JobTypes.CAPTURE_PRESENTATION, filename, presId, presLocation, allPages, pagesRange, parentMeetingId, presentationUploadToken)
val exportJob: ExportJob = ExportJob(jobId, JobTypes.CAPTURE_PRESENTATION, filename, presId, presLocation, allPages, pagesRange, parentMeetingId, presentationUploadToken)
val storeAnnotationPages: List[PresentationPageForExport] = getPresentationPagesForExport(pagesRange, pageCount, presId, currentPres, liveMeeting);
val annotationCount: Int = storeAnnotationPages.map(_.annotations.size).sum
@ -257,6 +258,10 @@ trait MakePresentationDownloadReqMsgHdlr extends RightsManagementTrait {
"filename" -> "annotated_slides.pdf"
)
ChatMessageDAO.insertSystemMsg(liveMeeting.props.meetingProp.intId, GroupChatApp.MAIN_PUBLIC_CHAT, "", GroupChatMessageType.PRESENTATION, presentationDownloadInfo, "")
} else if (m.body.fileStateType == "Converted") {
PresPresentationDAO.updatDownloadUri(m.body.presId, m.body.convertedFileURI)
} else if (m.body.fileStateType == "Original") {
PresPresentationDAO.updatDownloadUri(m.body.presId, m.body.originalFileURI)
}
bus.outGW.send(buildBroadcastNewPresFileAvailable(m, liveMeeting))

View File

@ -3,6 +3,7 @@ package org.bigbluebutton.core.apps.presentationpod
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.apps.{ PermissionCheck, RightsManagementTrait }
import org.bigbluebutton.core.bus.MessageBus
import org.bigbluebutton.core.db.PresPresentationDAO
import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.running.LiveMeeting
@ -51,6 +52,14 @@ trait SetPresentationDownloadablePubMsgHdlr extends RightsManagementTrait {
msg.header.userId, presentationId, downloadable, pres.name, downloadableExtension)
val pods = state.presentationPodManager.setPresentationDownloadableInPod(pod.id, presentationId, downloadable)
for {
pod <- pods.getPod(pod.id)
updatedPres <- pod.getPresentation(presentationId)
} yield {
PresPresentationDAO.insertOrUpdate(meetingId, updatedPres)
}
state.update(pods)
}

View File

@ -13,6 +13,7 @@ case class PresPageDbModel(
presentationId: String,
num: Int,
urls: String,
content: String,
slideRevealed: Boolean,
current: Boolean,
xOffset: Double,
@ -33,6 +34,7 @@ class PresPageDbTableDef(tag: Tag) extends Table[PresPageDbModel](tag, None, "pr
val presentationId = column[String]("presentationId")
val num = column[Int]("num")
val urls = column[String]("urls")
val content = column[String]("content")
val slideRevealed = column[Boolean]("slideRevealed")
val current = column[Boolean]("current")
val xOffset = column[Double]("xOffset")
@ -47,7 +49,7 @@ class PresPageDbTableDef(tag: Tag) extends Table[PresPageDbModel](tag, None, "pr
val maxImageHeight = column[Int]("maxImageHeight")
val converted = column[Boolean]("converted")
// val presentation = foreignKey("presentation_fk", presentationId, Presentations)(_.presentationId, onDelete = ForeignKeyAction.Cascade)
def * = (pageId, presentationId, num, urls, slideRevealed, current, xOffset, yOffset, widthRatio, heightRatio, width, height, viewBoxWidth, viewBoxHeight, maxImageWidth, maxImageHeight, converted) <> (PresPageDbModel.tupled, PresPageDbModel.unapply)
def * = (pageId, presentationId, num, urls, content, slideRevealed, current, xOffset, yOffset, widthRatio, heightRatio, width, height, viewBoxWidth, viewBoxHeight, maxImageWidth, maxImageHeight, converted) <> (PresPageDbModel.tupled, PresPageDbModel.unapply)
}
object PresPageDAO {

View File

@ -7,13 +7,25 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{ Failure, Success }
import spray.json._
case class PresPresentationDbModel(presentationId: String, meetingId: String, current: Boolean, downloadable: Boolean, removable: Boolean, uploadCompleted: Boolean, numPages: Int, errorMsgKey: String, errorDetails: String)
case class PresPresentationDbModel(
presentationId: String,
meetingId: String,
current: Boolean,
downloadable: Boolean,
downloadFileUri: Option[String],
removable: Boolean,
uploadCompleted: Boolean,
numPages: Int,
errorMsgKey: String,
errorDetails: String
)
class PresPresentationDbTableDef(tag: Tag) extends Table[PresPresentationDbModel](tag, None, "pres_presentation") {
val presentationId = column[String]("presentationId", O.PrimaryKey)
val meetingId = column[String]("meetingId")
val current = column[Boolean]("current")
val downloadable = column[Boolean]("downloadable")
val downloadFileUri = column[Option[String]]("downloadFileUri")
val removable = column[Boolean]("removable")
val uploadCompleted = column[Boolean]("uploadCompleted")
val numPages = column[Int]("numPages")
@ -21,7 +33,7 @@ class PresPresentationDbTableDef(tag: Tag) extends Table[PresPresentationDbModel
val errorDetails = column[String]("errorDetails")
// val meeting = foreignKey("meeting_fk", meetingId, Meetings)(_.meetingId, onDelete = ForeignKeyAction.Cascade)
def * = (presentationId, meetingId, current, downloadable, removable, uploadCompleted, numPages, errorMsgKey, errorDetails) <> (PresPresentationDbModel.tupled, PresPresentationDbModel.unapply)
def * = (presentationId, meetingId, current, downloadable, downloadFileUri, removable, uploadCompleted, numPages, errorMsgKey, errorDetails) <> (PresPresentationDbModel.tupled, PresPresentationDbModel.unapply)
}
object PresPresentationDAO {
@ -39,6 +51,7 @@ object PresPresentationDAO {
meetingId = meetingId,
current = false, //Set after pages were inserted
downloadable = presentation.downloadable,
downloadFileUri = None,
removable = presentation.removable,
uploadCompleted = presentation.uploadCompleted,
numPages = presentation.numPages,
@ -60,6 +73,7 @@ object PresPresentationDAO {
presentationId = presentation.id,
num = page._2.num,
urls = page._2.urls.toJson.asJsObject.compactPrint,
content = "Slide Content TODO", //TODO Get content from slide.txtUri (bbb-web should send its content)
slideRevealed = page._2.current,
current = page._2.current,
xOffset = page._2.xOffset,
@ -102,6 +116,18 @@ object PresPresentationDAO {
}
}
def updatDownloadUri(presentationId: String, downloadFileUri: String) = {
DatabaseConnection.db.run(
TableQuery[PresPresentationDbTableDef]
.filter(_.presentationId === presentationId)
.map(p => p.downloadFileUri)
.update(Some(downloadFileUri))
).onComplete {
case Success(rowAffected) => DatabaseConnection.logger.debug(s"$rowAffected row(s) updated originalFileURI on PresPresentation table")
case Failure(e) => DatabaseConnection.logger.error(s"Error updating originalFileURI on PresPresentation: $e")
}
}
def updateErrors(presentationId: String, errorMsgKey: String, errorDetails: scala.collection.immutable.Map[String, String]) = {
DatabaseConnection.db.run(
TableQuery[PresPresentationDbTableDef]

View File

@ -844,6 +844,7 @@ CREATE TABLE "pres_presentation" (
"meetingId" varchar(100) REFERENCES "meeting"("meetingId") ON DELETE CASCADE,
"current" boolean,
"downloadable" boolean,
"downloadFileUri" varchar(500),
"removable" boolean,
"converting" boolean,
"uploadCompleted" boolean,
@ -859,6 +860,7 @@ CREATE TABLE "pres_page" (
"presentationId" varchar(100) REFERENCES "pres_presentation"("presentationId") ON DELETE CASCADE,
"num" integer,
"urls" TEXT,
"content" TEXT,
"slideRevealed" boolean default false,
"current" boolean,
"xOffset" NUMERIC,
@ -881,6 +883,7 @@ SELECT pres_presentation."meetingId",
pres_presentation."presentationId",
pres_presentation."current",
pres_presentation."downloadable",
pres_presentation."downloadFileUri",
pres_presentation."removable",
pres_presentation."converting",
pres_presentation."uploadCompleted",
@ -896,6 +899,7 @@ SELECT pres_presentation."meetingId",
pres_page."pageId",
pres_page.num,
pres_page.urls,
pres_page.content,
pres_page."slideRevealed",
CASE WHEN pres_presentation."current" IS TRUE AND pres_page."current" IS TRUE THEN true ELSE false END AS "isCurrentPage",
pres_page."xOffset",
@ -919,9 +923,12 @@ SELECT pres_presentation."meetingId",
pres_page."presentationId",
pres_page."pageId",
pres_presentation."downloadable",
case when pres_presentation."downloadable" then pres_presentation."downloadFileUri" else null end "downloadFileUri",
pres_presentation."removable",
pres_presentation."numPages",
pres_page.num,
pres_page.urls,
pres_page.content,
pres_page."slideRevealed",
CASE WHEN pres_presentation."current" IS TRUE AND pres_page."current" IS TRUE THEN true ELSE false END AS "isCurrentPage",
pres_page."xOffset",

View File

@ -20,11 +20,13 @@ select_permissions:
- role: bbb_client
permission:
columns:
- content
- height
- heightRatio
- isCurrentPage
- num
- pageId
- presentationId
- scaledHeight
- scaledViewBoxHeight
- scaledViewBoxWidth

View File

@ -10,12 +10,16 @@ select_permissions:
- role: bbb_client
permission:
columns:
- content
- downloadFileUri
- downloadable
- height
- heightRatio
- isCurrentPage
- num
- numPages
- pageId
- presentationId
- removable
- scaledHeight
- scaledViewBoxHeight