diff --git a/app/controllers/bigbluebutton_api_controller.rb b/app/controllers/bigbluebutton_api_controller.rb index 424021fd..60326875 100644 --- a/app/controllers/bigbluebutton_api_controller.rb +++ b/app/controllers/bigbluebutton_api_controller.rb @@ -212,6 +212,9 @@ def create # Read the body if POST body = request.post? ? request.body.read : '' + # Override body with default presentations if empty + body = generate_default_presentations unless body != '' + # Send a GET/POST request to the server response = get_post_req(uri, body, **bbb_req_timeout(server)) rescue BBBError diff --git a/app/controllers/concerns/api_helper.rb b/app/controllers/concerns/api_helper.rb index dbce969f..218b79f9 100644 --- a/app/controllers/concerns/api_helper.rb +++ b/app/controllers/concerns/api_helper.rb @@ -217,3 +217,19 @@ def add_additional_params(action, bbb_params) final_params end end + +def generate_default_presentations + return '' if Rails.configuration.x.default_presentations.empty? + doc = Nokogiri::XML('') + module_pres = Nokogiri::XML::Node.new("module", doc) + module_pres['name'] = "presentation" + + Rails.configuration.x.default_presentations.each { |x| + document = Nokogiri::XML::Node.new("document", doc) + document['url'] = x[0] + document['filename'] = x[1] + module_pres << document + } + doc.root << module_pres + doc.to_xml +end diff --git a/config/application.rb b/config/application.rb index 79fc7956..a5a63cb8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -138,6 +138,8 @@ class Application < Rails::Application config.i18n.default_locale = ENV.fetch('DEFAULT_LOCALE', 'en') + config.x.default_presentations = ENV.fetch('DEFAULT_PRESENTATIONS', '').split(",").collect { |x| x.split('->') } + # Comma separated list of create params that can be overridden by the client config.x.default_create_params = ENV.fetch('DEFAULT_CREATE_PARAMS', '') .split(',').to_h { |param| param.split('=', 2) }.symbolize_keys diff --git a/docs/configuration-README.md b/docs/configuration-README.md index ae986da0..5eb14259 100644 --- a/docs/configuration-README.md +++ b/docs/configuration-README.md @@ -59,6 +59,7 @@ These variables are used by the service startup scripts in the Docker images, bu * `OVERRIDE_CREATE_PARAMS`: Sets a list of params on the create call that CANNOT be overridden by the client/requester. Should be in the format 'OVERRIDE_CREATE_PARAMS=param1=param1value,param2=param2value' * `DEFAULT_JOIN_PARAMS`: Sets a list of default params on the join call that CAN be overridden by the client/requester. Should be in the format 'DEFAULT_JOIN_PARAMS=param1=param1value,param2=param2value' * `OVERRIDE_JOIN_PARAMS`: Sets a list of params on the create call that CANNOT be overridden by the client/requester. Should be in the format 'OVERRIDE_JOIN_PARAMS=param1=param1value,param2=param2value' +* `DEFAULT_PRESENTATIONS`: Sets a list of default presentations on the create call. Will only trigger when a GET-request is used, otherwise the supplied body will be used. Should be in the format 'DEFAULT_PRESENTATIONS=http://presurl->presname.pdf,http://presurl2->presname2.pdf' * `GET_RECORDINGS_API_FILTERED`: Prevent get_recordings api from returning all recordings when recordID is not specified in the request, by setting value to 'true'. Defaults to false. * `PREPARED_STATEMENT`: Enable/Disable Active Record prepared statements feature, can be disabled by setting the value as `false`. Defaults to `true`. * `DB_CONNECTION_RETRY_COUNT`: The number of times db connection retries will be attempted, in case of a db connection failure. Defaults to `3`.