Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature (api): Add preUploadedPresentation param to API's /create via GET #18953

Merged
merged 5 commits into from Oct 19, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,6 +21,7 @@ package org.bigbluebutton.web.controllers
import com.google.gson.Gson
import grails.web.context.ServletContextHolder
import groovy.json.JsonBuilder
import groovy.xml.MarkupBuilder
import org.apache.commons.codec.binary.Base64
import org.apache.commons.codec.digest.DigestUtils
import org.apache.commons.io.FilenameUtils
Expand Down Expand Up @@ -1378,6 +1379,27 @@ class ApiController {
Boolean isDefaultPresentationCurrent = false;
def listOfPresentation = []
def presentationListHasCurrent = false
Boolean hasPresentationUrlInParameter = false


String[] pu = request.getParameterMap().get("preUploadedPresentation")
if (pu != null) {
String preUploadedPresentation = pu[0]
hasPresentationUrlInParameter = true
def xmlString = new StringWriter()
def xml = new MarkupBuilder(xmlString)
xml.document (
removable: "true",
downloadable: "false",
url: preUploadedPresentation,
filename: extractFilenameFromUrl(preUploadedPresentation),
name: extractFilenameFromUrl(preUploadedPresentation)
)

def parsedXml = new XmlSlurper().parseText(xmlString.toString())

listOfPresentation << parsedXml
}

// This part of the code is responsible for organize the presentations in a certain order
// It selects the one that has the current=true, and put it in the 0th place.
Expand All @@ -1387,10 +1409,17 @@ class ApiController {
log.warn("Insert Document API called without a payload - ignoring")
return;
}
listOfPresentation << [name: "default", current: true];
if (hasPresentationUrlInParameter) {
if (!preUploadedPresentationOverrideDefault) {
listOfPresentation << [name: "default", current: false]
gustavotrott marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
listOfPresentation << [name: "default", current: true]
}

} else {
def xml = new XmlSlurper().parseText(requestBody);
Boolean hasCurrent = false;
Boolean hasCurrent = hasPresentationUrlInParameter;
xml.children().each { module ->
log.debug("module config found: [${module.@name}]");

Expand Down Expand Up @@ -1478,6 +1507,10 @@ class ApiController {
return true
}

def extractFilenameFromUrl(String url) {
return url.split('/')[-1]
}
GuiLeme marked this conversation as resolved.
Show resolved Hide resolved

def processDocumentFromRawBytes(bytes, presOrigFilename, meetingId, current, isDownloadable, isRemovable,
isInitialPresentation) {
def uploadFailed = false
Expand Down