Repository navigation
feat(akka): Plugin Js relative entrypoint and refactor of pluginManifests parameter - #21485
Conversation
…t the name and extension
…and adapt all the rest.
WalkthroughThe pull request introduces several modifications across multiple files, primarily focusing on the handling of plugin manifests within the BigBlueButton application. Key changes include the addition of a new method, Additionally, renaming conventions have been standardized throughout the codebase, changing instances of "PluginsManifest" to "PluginManifest" to reflect a singular form. This includes updates in various classes such as Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (2)
bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.java (2)
431-455: Approved: Method renaming and consistent updatesThe renaming of
processPluginsManifeststoprocessPluginManifestsand the corresponding updates to parameter and variable names are consistent with the PR objectives. The logic remains unchanged, which is good for maintaining functionality.However, there are a couple of suggestions for improvement:
- Consider using a more specific exception instead of the generic
Exceptionin the catch block.- The error message could be more informative by including the actual exception details.
Consider updating the error handling as follows:
- } catch(Exception e) { - log.error("Couldn't decode the filters"); + } catch(JsonSyntaxException e) { + log.error("Error parsing pluginManifests JSON: {}", e.getMessage(), e);This change would provide more specific error handling and logging, making it easier to diagnose issues in the future.
577-587: Approved: Consistent processing of plugin manifestsThe changes in this segment are consistent with the renaming convention and properly handle both default and parameter-provided plugin manifests.
Suggestions for improvement:
- Consider extracting the plugin manifest processing logic into a separate method to improve readability and maintainability.
- Use
StringUtils.isNotEmpty()for consistency with other parts of the code.Consider refactoring the code as follows:
ArrayList<PluginManifest> listOfPluginManifests = new ArrayList<PluginManifest>(); -//Process plugins from config -if(defaultPluginManifests != null && !defaultPluginManifests.isEmpty()) { - ArrayList<PluginManifest> pluginManifestsFromConfig = processPluginManifests(defaultPluginManifests); - listOfPluginManifests.addAll(pluginManifestsFromConfig); -} -//Process plugins from /create param -String pluginManifestsParam = params.get(ApiParams.PLUGIN_MANIFESTS); -if (!StringUtils.isEmpty(pluginManifestsParam)) { - ArrayList<PluginManifest> pluginManifestsFromParam = processPluginManifests(pluginManifestsParam); - listOfPluginManifests.addAll(pluginManifestsFromParam); -} +listOfPluginManifests.addAll(processPluginManifestsSource(defaultPluginManifests)); +listOfPluginManifests.addAll(processPluginManifestsSource(params.get(ApiParams.PLUGIN_MANIFESTS))); + +private ArrayList<PluginManifest> processPluginManifestsSource(String source) { + if (StringUtils.isNotEmpty(source)) { + return processPluginManifests(source); + } + return new ArrayList<>(); +}This refactoring improves code readability and reduces duplication.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (8)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Plugins.scala (2 hunks)
- bbb-common-web/src/main/java/org/bigbluebutton/api/ApiParams.java (1 hunks)
- bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (3 hunks)
- bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.java (5 hunks)
- bbb-common-web/src/main/java/org/bigbluebutton/api/domain/Meeting.java (5 hunks)
- bbb-common-web/src/main/java/org/bigbluebutton/api/domain/PluginManifest.java (1 hunks)
- bigbluebutton-web/grails-app/conf/bigbluebutton.properties (1 hunks)
- bigbluebutton-web/grails-app/conf/spring/resources.xml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
- bigbluebutton-web/grails-app/conf/bigbluebutton.properties
🧰 Additional context used
🔇 Additional comments (19)
bbb-common-web/src/main/java/org/bigbluebutton/api/domain/PluginManifest.java (3)
7-12: LGTM! Constructor updated correctly.The constructor has been properly renamed to match the new class name
PluginManifest. The parameters and functionality remain unchanged, which is correct.
13-15: LGTM! Second constructor updated correctly.The second constructor has also been properly renamed to match the new class name
PluginManifest. The parameter and functionality remain unchanged, which is correct.
3-3: LGTM! Verify usage across the codebase.The class renaming from
PluginsManifesttoPluginManifestaligns with the PR objectives and improves consistency. Ensure that all references to this class have been updated throughout the codebase.Run the following script to verify the class usage:
✅ Verification successful
Verified: Class renaming is complete.
All references to
PluginsManifesthave been successfully updated toPluginManifestacross the codebase.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all occurrences of PluginManifest (new) and PluginsManifest (old) in the codebase. # Test: Search for the new class name. Expect: Only occurrences of the new name. echo "Occurrences of new class name 'PluginManifest':" rg -i 'PluginManifest' # Test: Search for the old class name. Expect: No occurrences of the old name. echo "Occurrences of old class name 'PluginsManifest':" rg -i 'PluginsManifest'Length of output: 7538
bbb-common-web/src/main/java/org/bigbluebutton/api/ApiParams.java (1)
76-76: LGTM! Verify usage across the codebase.The renaming of
PLUGINS_MANIFESTStoPLUGIN_MANIFESTSand its value from "pluginsManifests" to "pluginManifests" aligns with the PR objectives and improves consistency. This change looks good, but it's important to ensure that all references to this constant throughout the codebase have been updated accordingly.To verify the constant usage, run the following script:
bigbluebutton-web/grails-app/conf/spring/resources.xml (3)
204-204: LGTM: Consistent property renamingThe change from
pluginsManifeststopluginManifestsis approved. This renaming aligns with similar updates across the codebase, improving consistency and adhering to standard naming conventions. The singular form is more appropriate for this context.
Line range hint
220-221: Note on configuration managementThe comment about moving the import of 'turn-stun-servers.xml' to 'resources.groovy' indicates an ongoing effort to improve configuration management. This change allows for more flexible overlay configuration of TURN/STUN servers. While not part of the current PR's changes, it's worth noting for developers working on related system components.
Line range hint
1-222: Summary: Consistent refactoring and noted configuration changesThe changes in this file are minimal but align well with the PR's objectives. The renaming of
pluginsManifeststopluginManifestscontributes to the overall consistency of the codebase. The commented-out import statement, while not part of the active changes, provides insight into ongoing configuration management improvements. Overall, these changes maintain the file's integrity as a Spring configuration file while enhancing code consistency.bbb-common-web/src/main/java/org/bigbluebutton/api/domain/Meeting.java (4)
82-82: LGTM: Field renamed consistently with PR objective.The field has been correctly renamed from
pluginsManifeststopluginManifests, maintaining consistency with the PR's goal. The typeArrayList<PluginManifest>suggests that related changes have been made elsewhere in the codebase.
455-456: LGTM: Getter method renamed consistently.The getter method has been correctly renamed from
getPluginsManifests()togetPluginManifests(), maintaining consistency with the field renaming and adhering to Java naming conventions for getter methods.
1081-1082: LGTM: Builder method renamed consistently.The builder method has been correctly renamed from
withPluginsManifeststowithPluginManifests, maintaining consistency with the field renaming and adhering to the builder pattern naming convention.
82-82: Verify external references and usage of renamed elements.The renaming from
pluginsManifeststopluginManifestshas been consistently applied across theMeetingclass. However, it's crucial to ensure that this change doesn't break any existing functionality or external references.Please run the following script to check for any remaining occurrences of
pluginsManifestsin the codebase and verify that all usages have been updated:Also applies to: 455-456, 1081-1082
✅ Verification successful
Renaming Verified Successfully
The renaming from
pluginsManifeststopluginManifestshas been successfully applied across the codebase with no remaining occurrences ofpluginsManifests.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any remaining occurrences of 'pluginsManifests' and verify usage updates # Search for any remaining occurrences of 'pluginsManifests' echo "Searching for remaining occurrences of 'pluginsManifests':" rg -i 'pluginsManifests' # Search for usages of the new 'pluginManifests' to verify updates echo "Verifying usage of the new 'pluginManifests':" rg -i 'pluginManifests'Length of output: 5115
bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (5)
407-407: Refactoring: Singular form used for plugin manifest iterationThe change from
pluginsManifeststopluginManifestsaligns with the PR objectives of refactoring the parameter name. This improves consistency throughout the codebase.
410-410: Improved error handling and loggingThe error handling has been enhanced with more specific logging. This change provides better context for debugging and monitoring.
- log.error("Failed to get content from " + urlString); + log.error("Failed with the following plugin manifest URL: {}. Error: ", + pluginManifest.getUrl(), e); + log.error("Therefore this plugin will not be loaded");Also applies to: 424-424, 429-429, 432-432, 461-461
Line range hint
407-461: Overall improvement in plugin manifest handlingThe changes to the
requestPluginManifestsmethod significantly improve the handling of plugin manifests:
- Consistent naming convention (singular form) is used.
- Each plugin manifest is processed individually, increasing flexibility.
- Error handling and logging have been enhanced.
- JSON parsing now uses the Jackson library, which is more robust.
- A new feature for metadata parameter replacement has been added.
These changes align well with the PR objectives and should improve the overall functionality and maintainability of the plugin system.
Line range hint
439-457: New feature: Metadata parameter replacement in manifest contentA new feature has been added to replace metadata parameters in the manifest content. This enhances the flexibility of plugin configurations.
However, we should verify if this new feature is properly documented:
#!/bin/bash # Check if the new metadata replacement feature is documented rg -i 'metadata\s+parameter\s+replacement' --type md
Line range hint
410-438: Enhanced plugin manifest processingThe method now processes each plugin manifest individually, fetches its content, and performs various operations such as checksum validation and JSON parsing. This approach is more flexible and robust.
However, there's a potential issue with the checksum validation:
✅ Verification successful
It seems there was a syntax error in your shell script due to an unmatched backtick. Here's the corrected script to verify if the checksum validation using
DigestUtils.sha256Hexis consistent across the Java codebase:
Checksum Validation Consistent Across Codebase
The checksum validation using
DigestUtils.sha256Hexis consistently implemented inbbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java. No inconsistencies found.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify if the checksum validation is consistent across the codebase rg -U 'String\s+hash\s*=\s*DigestUtils\.sha256Hex\(' --type javaLength of output: 148
Script:
#!/bin/bash # Verify if the checksum validation using DigestUtils.sha256Hex is consistent across the Java codebase rg -U 'String\s+hash\s*=\s*DigestUtils\.sha256Hex\(' --type javaLength of output: 204
Script:
#!/bin/bash # Verify if the checksum validation using DigestUtils.sha256Hex is consistent across the Java codebase rg -U 'String\s+hash\s*=\s*DigestUtils\.sha256Hex\(' --type javaLength of output: 204
bbb-common-web/src/main/java/org/bigbluebutton/api/ParamsProcessorUtil.java (3)
102-102: Approved: Consistent renaming of variableThe renaming of
defaultPluginsManifeststodefaultPluginManifestsis consistent with the PR objectives and improves naming consistency throughout the codebase.
1623-1624: Approved: Consistent renaming of setter methodThe renaming of
setPluginsManifeststosetPluginManifestsis consistent with the PR objectives and improves naming consistency throughout the codebase.
Line range hint
1-1624: Summary: Consistent renaming with minor improvement suggestionsThe changes in this file successfully implement the renaming of "pluginsManifests" to "pluginManifests" throughout the
ParamsProcessorUtilclass. This improves naming consistency and aligns with the PR objectives. The functionality remains unchanged, which is good for maintaining backwards compatibility.A few minor suggestions for improvement have been made:
- Enhancing error handling in the
processPluginManifestsmethod.- Refactoring the plugin manifest processing logic for better readability and maintainability.
These suggestions are not critical and can be addressed in a future PR if desired. Overall, the changes meet the objectives and maintain the existing functionality.
| var javascriptEntrypointUrl: String, | ||
| javascriptEntrypointIntegrity: Option[String] = None, | ||
| localesBaseUrl: Option[String] = None, | ||
| eventPersistence: Option[EventPersistence] = None, | ||
| dataChannels: Option[List[DataChannel]] = None, | ||
| remoteDataSources: Option[List[RemoteDataSource]] = None | ||
| ) | ||
| ) { | ||
| def setJavascriptEntrypointUrl(newUrl: String) = { | ||
| this.javascriptEntrypointUrl = newUrl | ||
| } | ||
| } |
There was a problem hiding this comment.
Consider keeping PluginManifestContent immutable
Changing javascriptEntrypointUrl from a val to a var introduces mutability into PluginManifestContent, which is a case class. In Scala, it's best practice to keep case classes immutable for thread safety and maintainability. Instead of making the field mutable and adding a setter method, consider creating a new instance with the updated javascriptEntrypointUrl.
Apply this diff to keep PluginManifestContent immutable:
case class PluginManifestContent(
requiredSdkVersion: String,
name: String,
- var javascriptEntrypointUrl: String,
+ javascriptEntrypointUrl: String,
javascriptEntrypointIntegrity: Option[String] = None,
localesBaseUrl: Option[String] = None,
eventPersistence: Option[EventPersistence] = None,
dataChannels: Option[List[DataChannel]] = None,
remoteDataSources: Option[List[RemoteDataSource]] = None
) {
- def setJavascriptEntrypointUrl(newUrl: String) = {
- this.javascriptEntrypointUrl = newUrl
- }
}Then, update replaceRelativeJavascriptEntrypoint to return a new Plugin instance with the updated javascriptEntrypointUrl:
def replaceRelativeJavascriptEntrypoint(plugin: Plugin): Plugin = {
- val pluginWithAbsoluteJavascriptEntrypoint = plugin.copy()
val jsEntrypoint = plugin.manifest.content.javascriptEntrypointUrl
if (jsEntrypoint.startsWith("http://") || jsEntrypoint.startsWith("https://")) {
- pluginWithAbsoluteJavascriptEntrypoint
+ plugin
} else {
- val baseUrl = plugin.manifest.url.substring(0, plugin.manifest.url.lastIndexOf('/') + 1)
- val absoluteJavascriptEntrypoint = baseUrl + jsEntrypoint
- pluginWithAbsoluteJavascriptEntrypoint.manifest.content.setJavascriptEntrypointUrl(absoluteJavascriptEntrypoint)
- pluginWithAbsoluteJavascriptEntrypoint
+ val baseUrl = plugin.manifest.url.substring(0, plugin.manifest.url.lastIndexOf('/') + 1)
+ val absoluteJavascriptEntrypoint = baseUrl + jsEntrypoint
+ val updatedContent = plugin.manifest.content.copy(
+ javascriptEntrypointUrl = absoluteJavascriptEntrypoint
+ )
+ val updatedManifest = plugin.manifest.copy(
+ content = updatedContent
+ )
+ plugin.copy(
+ manifest = updatedManifest
+ )
}
}This approach maintains immutability and avoids unintended side effects caused by mutating shared objects.
Committable suggestion was skipped due to low confidence.
| val baseUrl = plugin.manifest.url.substring(0, plugin.manifest.url.lastIndexOf('/') + 1) | ||
| val absoluteJavascriptEntrypoint = baseUrl + jsEntrypoint | ||
| pluginWithAbsoluteJavascriptEntrypoint.manifest.content.setJavascriptEntrypointUrl(absoluteJavascriptEntrypoint) |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Use java.net.URL for safer URL manipulation
Manually manipulating URLs using substring and concatenation can be error-prone, especially with complex URLs. Consider using java.net.URL to handle URL resolution more robustly.
Apply this diff to use URL for resolving the JavaScript entry point:
val jsEntrypoint = plugin.manifest.content.javascriptEntrypointUrl
if (jsEntrypoint.startsWith("http://") || jsEntrypoint.startsWith("https://")) {
pluginWithAbsoluteJavascriptEntrypoint
} else {
- val baseUrl = plugin.manifest.url.substring(0, plugin.manifest.url.lastIndexOf('/') + 1)
- val absoluteJavascriptEntrypoint = baseUrl + jsEntrypoint
+ val manifestUrl = new java.net.URL(plugin.manifest.url)
+ val absoluteJavascriptEntrypoint = new java.net.URL(manifestUrl, jsEntrypoint).toString
val updatedContent = pluginWithAbsoluteJavascriptEntrypoint.manifest.content.copy(
javascriptEntrypointUrl = absoluteJavascriptEntrypoint
)This approach correctly resolves relative paths against the manifest URL, handling edge cases effectively.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| val baseUrl = plugin.manifest.url.substring(0, plugin.manifest.url.lastIndexOf('/') + 1) | |
| val absoluteJavascriptEntrypoint = baseUrl + jsEntrypoint | |
| pluginWithAbsoluteJavascriptEntrypoint.manifest.content.setJavascriptEntrypointUrl(absoluteJavascriptEntrypoint) | |
| val manifestUrl = new java.net.URL(plugin.manifest.url) | |
| val absoluteJavascriptEntrypoint = new java.net.URL(manifestUrl, jsEntrypoint).toString | |
| val updatedContent = pluginWithAbsoluteJavascriptEntrypoint.manifest.content.copy( | |
| javascriptEntrypointUrl = absoluteJavascriptEntrypoint | |
| ) |
| def replaceRelativeJavascriptEntrypoint(plugin: Plugin): Plugin = { | ||
| val pluginWithAbsoluteJavascriptEntrypoint = plugin.copy() | ||
| val jsEntrypoint = plugin.manifest.content.javascriptEntrypointUrl | ||
| if (jsEntrypoint.startsWith("http://") || jsEntrypoint.startsWith("https://")) { | ||
| pluginWithAbsoluteJavascriptEntrypoint | ||
| } else { | ||
| val baseUrl = plugin.manifest.url.substring(0, plugin.manifest.url.lastIndexOf('/') + 1) | ||
| val absoluteJavascriptEntrypoint = baseUrl + jsEntrypoint | ||
| pluginWithAbsoluteJavascriptEntrypoint.manifest.content.setJavascriptEntrypointUrl(absoluteJavascriptEntrypoint) | ||
| pluginWithAbsoluteJavascriptEntrypoint | ||
| } | ||
| } |
There was a problem hiding this comment.
Ensure deep copying to prevent unintended side effects
The plugin.copy() method creates a shallow copy of the Plugin, so nested objects like manifest and content are still shared between the original and the copy. Mutating pluginWithAbsoluteJavascriptEntrypoint.manifest.content could inadvertently affect the original plugin. To prevent this, perform a deep copy of the nested objects.
Apply this diff to perform a deep copy:
def replaceRelativeJavascriptEntrypoint(plugin: Plugin): Plugin = {
- val pluginWithAbsoluteJavascriptEntrypoint = plugin.copy()
+ val pluginWithAbsoluteJavascriptEntrypoint = plugin.copy(
+ manifest = plugin.manifest.copy(
+ content = plugin.manifest.content.copy()
+ )
+ )
val jsEntrypoint = plugin.manifest.content.javascriptEntrypointUrl
if (jsEntrypoint.startsWith("http://") || jsEntrypoint.startsWith("https://")) {
pluginWithAbsoluteJavascriptEntrypoint
} else {
val baseUrl = plugin.manifest.url.substring(0, plugin.manifest.url.lastIndexOf('/') + 1)
val absoluteJavascriptEntrypoint = baseUrl + jsEntrypoint
- pluginWithAbsoluteJavascriptEntrypoint.manifest.content.setJavascriptEntrypointUrl(absoluteJavascriptEntrypoint)
+ val updatedContent = pluginWithAbsoluteJavascriptEntrypoint.manifest.content.copy(
+ javascriptEntrypointUrl = absoluteJavascriptEntrypoint
+ )
+ val updatedManifest = pluginWithAbsoluteJavascriptEntrypoint.manifest.copy(
+ content = updatedContent
+ )
+ pluginWithAbsoluteJavascriptEntrypoint.copy(
+ manifest = updatedManifest
+ )
}
}This ensures that modifications do not affect the original plugin instance.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| def replaceRelativeJavascriptEntrypoint(plugin: Plugin): Plugin = { | |
| val pluginWithAbsoluteJavascriptEntrypoint = plugin.copy() | |
| val jsEntrypoint = plugin.manifest.content.javascriptEntrypointUrl | |
| if (jsEntrypoint.startsWith("http://") || jsEntrypoint.startsWith("https://")) { | |
| pluginWithAbsoluteJavascriptEntrypoint | |
| } else { | |
| val baseUrl = plugin.manifest.url.substring(0, plugin.manifest.url.lastIndexOf('/') + 1) | |
| val absoluteJavascriptEntrypoint = baseUrl + jsEntrypoint | |
| pluginWithAbsoluteJavascriptEntrypoint.manifest.content.setJavascriptEntrypointUrl(absoluteJavascriptEntrypoint) | |
| pluginWithAbsoluteJavascriptEntrypoint | |
| } | |
| } | |
| def replaceRelativeJavascriptEntrypoint(plugin: Plugin): Plugin = { | |
| val pluginWithAbsoluteJavascriptEntrypoint = plugin.copy( | |
| manifest = plugin.manifest.copy( | |
| content = plugin.manifest.content.copy() | |
| ) | |
| ) | |
| val jsEntrypoint = plugin.manifest.content.javascriptEntrypointUrl | |
| if (jsEntrypoint.startsWith("http://") || jsEntrypoint.startsWith("https://")) { | |
| pluginWithAbsoluteJavascriptEntrypoint | |
| } else { | |
| val baseUrl = plugin.manifest.url.substring(0, plugin.manifest.url.lastIndexOf('/') + 1) | |
| val absoluteJavascriptEntrypoint = baseUrl + jsEntrypoint | |
| val updatedContent = pluginWithAbsoluteJavascriptEntrypoint.manifest.content.copy( | |
| javascriptEntrypointUrl = absoluteJavascriptEntrypoint | |
| ) | |
| val updatedManifest = pluginWithAbsoluteJavascriptEntrypoint.manifest.copy( | |
| content = updatedContent | |
| ) | |
| pluginWithAbsoluteJavascriptEntrypoint.copy( | |
| manifest = updatedManifest | |
| ) | |
| } | |
| } |
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Plugins.scala (1)
64-75: LGTM! Consider usingjava.net.URLfor robust URL handling.The implementation of
replaceRelativeJavascriptEntrypointcorrectly handles both absolute and relative JavaScript entry points while maintaining immutability. However, manually manipulating URLs with string operations might not handle all edge cases.Consider using
java.net.URLfor more robust URL handling:import java.net.URL def replaceRelativeJavascriptEntrypoint(plugin: Plugin): Plugin = { val jsEntrypoint = plugin.manifest.content.javascriptEntrypointUrl if (jsEntrypoint.startsWith("http://") || jsEntrypoint.startsWith("https://")) { plugin } else { val manifestUrl = new URL(plugin.manifest.url) val absoluteJavascriptEntrypoint = new URL(manifestUrl, jsEntrypoint).toString val newPluginManifestContent = plugin.manifest.content.copy(javascriptEntrypointUrl = absoluteJavascriptEntrypoint) val newPluginManifest = plugin.manifest.copy(content = newPluginManifestContent) plugin.copy(manifest = newPluginManifest) } }This approach will handle more complex URL scenarios correctly.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Plugins.scala (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Plugins.scala (1)
82-83: LGTM! Ensures consistent absolute URLs for JavaScript entry points.The changes in
createPluginModelFromJsoncorrectly apply thereplaceRelativeJavascriptEntrypointmethod to each plugin object. This ensures that all plugins processed from JSON have their JavaScript entry points set to absolute URLs, which aligns with the PR objectives.
Automated tests Summary🚨 Test workflow has failedClick here to check the action test reports |



What does this PR do?
This PR basically refactors the name
pluginsManifeststopluginManifestsparameter and makes necessary changes. Outside of that, it adds the possibility of sending a relative plugin js entrypoint in manifest. So now, the structure can Also be as follows:{ "requiredSdkVersion": "~0.0.59", "name": "H5pPlugin", "javascriptEntrypointUrl": "H5pPlugin.js", "localesBaseUrl": "https://cdn.dominio.com/pluginabc/", "eventPersistence": { "isEnabled": true, "maximumPayloadSizeInBytes": 1024, "rateLimiting": { "messagesAllowedPerSecond": 10, "messagesAllowedPerMinute": 20 } }, "dataChannels": [ { "name": "testResult", "pushPermission": ["moderator"], "replaceOrDeletePermission": ["creator", "moderator"] } ] }And the absolute js entrypoint would be the
baseUrlof themanifest.jsonconcatenated with the relative js entrypoint.If, on the other hand, we already have an absolute js entrypoint with
httporhttpsat the begining of the string, this new flow will be ignored.n