Skip to content

refactor (bbb-web): Add more info for Removed User Session. - #21436

Merged
gustavotrott merged 2 commits into
bigbluebutton:v3.0.x-releasefrom
gustavotrott:fix-checkGraphqlAuthorization-removedUserSession
Oct 15, 2024
Merged

gustavotrott merged 2 commits into
bigbluebutton:v3.0.x-releasefrom
gustavotrott:fix-checkGraphqlAuthorization-removedUserSession

Conversation

@gustavotrott

Copy link
Copy Markdown
Contributor

Add fullname, userExtId and meetingExtId to be stored for removed users, it will be useful for integrations.

Includes fullname, userExtId and meetingExtId, that will be useful for integrations.
@gustavotrott gustavotrott added this to the Release 3.0 milestone Oct 14, 2024
@coderabbitai

coderabbitai Bot commented Oct 14, 2024 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces updates to the MeetingService and ConnectionController classes within the BigBlueButton project. In the MeetingService class, new fields—extMeetingId, extUserId, and userFullName—have been added to the UserSessionBasicData class. These fields are populated during the execution of the removeUserSessionWithSessionToken method, which enhances the tracking of user information in the removedSessions map.

In the ConnectionController.groovy, the checkGraphqlAuthorization method has been modified to rename several fields for consistency and clarity. The fields externMeetingID, externUserID, and fullname have been renamed to extMeetingId, extUserId, and userFullName, respectively. This renaming is reflected in both the response headers and the JSON output structure. While the logic for checking user session validity remains unchanged, the updated field names are now utilized in the response, ensuring consistency across the application.

Possibly related PRs

Suggested reviewers

  • ramonlsouza

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Outside diff range and nitpick comments (3)
bbb-common-web/src/main/java/org/bigbluebutton/api/domain/UserSessionBasicData.java (2)

Line range hint 30-38: Update toString() method and consider adding a new constructor.

The new fields (extUserId, extMeetingId, and userFullName) are not included in the toString() method. Consider updating it to provide a more comprehensive string representation of the object.

Additionally, to facilitate the creation of objects with these new fields, consider adding a new constructor that includes all fields.

Here's a suggested update for the toString() method and a new constructor:

+ public UserSessionBasicData(String sessionToken, String userId, String extUserId, 
+                             String meetingId, String extMeetingId, String userFullName, String role) {
+     this.sessionToken = sessionToken;
+     this.userId = userId;
+     this.extUserId = extUserId;
+     this.meetingId = meetingId;
+     this.extMeetingId = extMeetingId;
+     this.userFullName = userFullName;
+     this.role = role;
+ }

  public String toString() {
-     return meetingId + " " + userId + " " + sessionToken;
+     return String.format("UserSessionBasicData[meetingId=%s, extMeetingId=%s, userId=%s, extUserId=%s, userFullName=%s, sessionToken=%s, role=%s]",
+         meetingId, extMeetingId, userId, extUserId, userFullName, sessionToken, role);
  }

This update provides a more informative toString() method and a constructor for easy object creation with all fields.


25-28: Overall assessment: Improvements needed for better encapsulation and completeness

The addition of extUserId, extMeetingId, and userFullName fields aligns well with the PR objectives of enhancing information for removed user sessions. However, there are several areas for improvement:

  1. Encapsulation: Consider making all fields private and providing getter/setter methods.
  2. toString() method: Update to include all fields for a comprehensive representation.
  3. Constructor: Add a new constructor that includes all fields for easier object creation.
  4. Consistency: Ensure that the changes are consistent with the overall design of the class and the broader system.

These improvements will enhance the robustness and maintainability of the UserSessionBasicData class while fulfilling the PR objectives.

bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ConnectionController.groovy (1)

118-121: LGTM! Consider a minor improvement for consistency.

The changes align well with the PR objectives, adding more information for removed user sessions. The new field names (extMeetingId, extUserId, and userFullName) are now consistent with the UserSessionBasicData class.

For better consistency, consider updating the header names to match the new field names:

- response.addHeader("Meeting-External-Id", removedUserSession.extMeetingId)
+ response.addHeader("Meeting-Ext-Id", removedUserSession.extMeetingId)
- response.addHeader("User-External-Id", removedUserSession.extUserId)
+ response.addHeader("User-Ext-Id", removedUserSession.extUserId)
- response.addHeader("User-Name", URLEncoder.encode(removedUserSession.userFullName, StandardCharsets.UTF_8.name()))
+ response.addHeader("User-Full-Name", URLEncoder.encode(removedUserSession.userFullName, StandardCharsets.UTF_8.name()))

This change would make the header names more consistent with the new field names and improve overall code readability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 1eeff8d and a926ffc.

📒 Files selected for processing (3)
  • bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (1 hunks)
  • bbb-common-web/src/main/java/org/bigbluebutton/api/domain/UserSessionBasicData.java (1 hunks)
  • bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ConnectionController.groovy (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ConnectionController.groovy (1)

118-121: Summary: Changes look good, with minor suggestions and verification needed.

Overall, the changes successfully implement the PR objectives by adding more information for removed user sessions. The new field names (extMeetingId, extUserId, and userFullName) are consistent with the UserSessionBasicData class.

To further improve the code:

  1. Consider updating the header names for consistency, as suggested earlier.
  2. Verify the impact of these changes on other parts of the codebase using the provided script.

These changes enhance the information available for removed user sessions, which should benefit integrations with other systems as intended.

bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java (2)

205-208: Approved: New fields added to enhance user session data

These changes align well with the PR objectives. The addition of extMeetingId, extUserId, and userFullName fields to the UserSessionBasicData object provides more detailed information about removed user sessions, which will be beneficial for integrations with other systems.

The implementation is clean and consistent with the existing code style.


205-208: Summary: Enhanced user session data for improved integration

The changes in this file successfully implement the PR objectives by adding more detailed information to the UserSessionBasicData object for removed user sessions. The new fields (extMeetingId, extUserId, and userFullName) provide valuable context that will be beneficial for integrations with other systems.

These additions are well-implemented, consistent with the existing code style, and do not introduce any apparent issues. The enhanced data will improve the overall functionality and interoperability of the application as intended.

public String extUserId = null;
public String meetingId = null;
public String extMeetingId = null;
public String userFullName = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using private access modifier with getter/setter methods for userFullName.

The userFullName field should also follow encapsulation principles. Making it private with getter/setter methods would be more aligned with Java best practices and consistent with the suggestions for the other new fields.

Here's a suggested refactor:

- public String userFullName = null;
+ private String userFullName = null;

+ public String getUserFullName() {
+     return userFullName;
+ }

+ public void setUserFullName(String userFullName) {
+     this.userFullName = userFullName;
+ }
📝 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.

Suggested change
public String userFullName = null;
private String userFullName = null;
public String getUserFullName() {
return userFullName;
}
public void setUserFullName(String userFullName) {
this.userFullName = userFullName;
}

public String userId = null;
public String extUserId = null;
public String meetingId = null;
public String extMeetingId = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using private access modifier with getter/setter methods for extMeetingId.

Similar to the extUserId field, the extMeetingId should also follow encapsulation principles. Making it private with getter/setter methods would be more aligned with Java best practices.

Here's a suggested refactor:

- public String extMeetingId = null;
+ private String extMeetingId = null;

+ public String getExtMeetingId() {
+     return extMeetingId;
+ }

+ public void setExtMeetingId(String extMeetingId) {
+     this.extMeetingId = extMeetingId;
+ }

Committable suggestion was skipped due to low confidence.

public class UserSessionBasicData {
public String sessionToken = null;
public String userId = null;
public String extUserId = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider using private access modifier with getter/setter methods.

While adding the extUserId field aligns with the PR objectives, making it public might violate encapsulation principles. Consider making it private and providing getter/setter methods for controlled access. This approach would be more consistent with Java best practices and allow for future validation or logic in the accessor methods if needed.

Here's a suggested refactor:

- public String extUserId = null;
+ private String extUserId = null;

+ public String getExtUserId() {
+     return extUserId;
+ }

+ public void setExtUserId(String extUserId) {
+     this.extUserId = extUserId;
+ }

Committable suggestion was skipped due to low confidence.

Comment on lines +118 to +121
response.addHeader("Meeting-External-Id", removedUserSession.extMeetingId)
response.addHeader("User-Id", removedUserSession.internalUserId)
response.addHeader("User-External-Id", removedUserSession.externUserID)
response.addHeader("User-Name", URLEncoder.encode(removedUserSession.fullname, StandardCharsets.UTF_8.name()))
response.addHeader("User-External-Id", removedUserSession.extUserId)
response.addHeader("User-Name", URLEncoder.encode(removedUserSession.userFullName, StandardCharsets.UTF_8.name()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Multiple instances of old field names found in the codebase.

The shell script results indicate that externMeetingID and externUserID are still present in several files. Please update all occurrences of these old field names to the new names (extMeetingId and extUserId) to ensure consistency and prevent potential bugs.

🔗 Analysis chain

Verify impact on other parts of the codebase.

The changes to the field names for removed user sessions are localized to this file. However, it's important to ensure that these changes don't affect other parts of the codebase that might be expecting the old field names.

To verify the impact, please run the following script:

This script will help identify any potential areas that might need to be updated to maintain consistency with the new field names.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for usage of old field names in the codebase

# Search for old field names
echo "Searching for 'externMeetingID'..."
rg --type groovy --type java 'externMeetingID'

echo "Searching for 'externUserID'..."
rg --type groovy --type java 'externUserID'

echo "Searching for 'fullname' in the context of removed user sessions..."
rg --type groovy --type java 'fullname.*removedUserSession'

# Search for new field names to ensure they are used consistently
echo "Searching for 'extMeetingId'..."
rg --type groovy --type java 'extMeetingId'

echo "Searching for 'extUserId'..."
rg --type groovy --type java 'extUserId'

echo "Searching for 'userFullName'..."
rg --type groovy --type java 'userFullName'

Length of output: 8391

@gustavotrott
gustavotrott merged commit a52586f into bigbluebutton:v3.0.x-release Oct 15, 2024
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Automated tests Summary

🚨 Test workflow has failed


Click here to check the action test reports

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant