Skip to content

Allow to disable new chat features through the param disabledFeatures - #21354

Merged
antobinary merged 2 commits into
bigbluebutton:v3.0.x-releasefrom
gustavotrott:disabled-chat-feats
Oct 4, 2024
Merged

antobinary merged 2 commits into
bigbluebutton:v3.0.x-releasefrom
gustavotrott:disabled-chat-feats

Conversation

@gustavotrott

Copy link
Copy Markdown
Contributor

Allow to disable the new chat features through the param disabledFeatures.

  • deleteChatMessage
  • editChatMessage
  • replyChatMessage
  • chatMessageReactions

It affects only the backend once the frontend portion is under development.

@gustavotrott gustavotrott added this to the Release 3.0 milestone Oct 3, 2024
@coderabbitai

This comment was marked as off-topic.

@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 (11)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/SendGroupChatMessageReactionReqMsgHdlr.scala (2)

17-17: LGTM! Consider extracting the feature name to a constant.

The introduction of chatMessageReactionsDisabled aligns well with the PR objective. It correctly checks if the "chatMessageReactions" feature is disabled.

For improved readability and maintainability, consider extracting "chatMessageReactions" to a constant:

+  private val CHAT_MESSAGE_REACTIONS_FEATURE = "chatMessageReactions"
   val chatMessageReactionsDisabled: Boolean = liveMeeting.props.meetingProp.disabledFeatures.contains(CHAT_MESSAGE_REACTIONS_FEATURE)

This approach would make it easier to update the feature name if needed and reduce the risk of typos.


47-47: LGTM! Consider breaking down the condition for improved readability.

The modification correctly incorporates the new check for disabled chat message reactions, aligning with the PR objective. The logic ensures that reactions are only processed when appropriate.

For improved readability, consider breaking down the complex condition into smaller, named parts:

-      if (!chatDisabled && !chatMessageReactionsDisabled && !(applyPermissionCheck && chatLocked) && !chatLockedForUser) {
+      val featuresEnabled = !chatDisabled && !chatMessageReactionsDisabled
+      val permissionsAllowed = !(applyPermissionCheck && chatLocked) && !chatLockedForUser
+      if (featuresEnabled && permissionsAllowed) {

This approach makes the condition easier to understand and maintain.

akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/DeleteGroupChatMessageReactionReqMsgHdlr.scala (2)

17-17: LGTM! Consider extracting the feature name to a constant.

The addition of chatMessageReactionsDisabled aligns well with the PR objectives and follows the existing pattern. Good job!

For improved readability and maintainability, consider extracting the feature name "chatMessageReactions" to a constant. This would make it easier to update if the feature name changes in the future and improve consistency across the codebase. For example:

val ChatMessageReactionsFeature = "chatMessageReactions"
val chatMessageReactionsDisabled: Boolean = liveMeeting.props.meetingProp.disabledFeatures.contains(ChatMessageReactionsFeature)

47-47: LGTM! Consider refactoring for improved readability.

The addition of !chatMessageReactionsDisabled to the conditional statement correctly implements the feature disabling functionality. This change aligns well with the PR objectives and maintains consistency with existing checks.

To improve readability, consider refactoring the condition into smaller, named boolean expressions. This would make the code more self-documenting and easier to maintain. For example:

val featuresEnabled = !chatDisabled && !chatMessageReactionsDisabled
val permissionsAllowed = !(applyPermissionCheck && chatLocked) && !chatLockedForUser
if (featuresEnabled && permissionsAllowed) {
  // Existing code...
}

This refactoring would make the condition's intent clearer and easier to modify in the future if additional checks need to be added.

akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/DeleteGroupChatMessageReqMsgHdlr.scala (1)

48-48: Approve logic change, but consider refactoring for readability.

The modification correctly incorporates the new check for the disabled delete feature, ensuring that the deletion process only proceeds when both chatDisabled and deleteChatMessageDisabled are false. This aligns well with the PR objectives.

However, the line has become quite long. Consider refactoring for improved readability:

val deleteAllowed = !chatDisabled && !deleteChatMessageDisabled && !(applyPermissionCheck && chatLocked) && !chatLockedForUser
if (deleteAllowed) {
  // Existing code block
}

This refactoring maintains the same logic while improving readability and making future modifications easier.

akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/SendGroupChatMessageMsgHdlr.scala (1)

Line range hint 1-110: Overall implementation looks good, with a minor suggestion

The changes successfully implement the disabledFeatures functionality for the reply feature, aligning well with the PR objectives. The code maintains good practices such as immutability and clear variable naming.

As a minor suggestion for improvement:

Consider extracting the logic for clearing the replyToMessageId into a separate method for better readability and potential reuse. For example:

def clearReplyToMessageIdIfDisabled(msg: GroupChatMessage, isDisabled: Boolean): GroupChatMessage = {
  if (isDisabled && msg.replyToMessageId.nonEmpty) {
    msg.copy(replyToMessageId = "")
  } else {
    msg
  }
}

// Usage
val groupChatMsgReceived = clearReplyToMessageIdIfDisabled(msg.body.msg, replyChatMessageDisabled)

This refactoring would enhance code organization and make the main logic flow easier to follow.

akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/GroupChat.scala (1)

Line range hint 1-126: File review conclusion: Minor improvement, but incomplete feature implementation

The changes in this file represent a small improvement in code simplicity and consistency. However, they don't fully address the PR objectives of introducing a disabledFeatures parameter to disable specific chat features.

Consider the following points:

  1. The implementation of the disabledFeatures parameter is not visible in this file. Are there other files in this PR that implement this functionality?

  2. If this is the only change in the PR, it might be beneficial to split this into a separate, smaller PR for code cleanup, and create a new PR for the feature disabling functionality.

  3. Update the PR description to accurately reflect the changes made in this commit if the scope has changed.

bigbluebutton-web/grails-app/conf/bigbluebutton.properties (1)

Line range hint 468-474: Approval of legacy property updates with a suggestion

The updates to the comments for learningDashboardEnabled, breakoutRoomsEnabled, and allowDuplicateExtUserid are appropriate and provide clear guidance on the deprecation of these properties. This aligns well with the overall objective of introducing the disabledFeatures parameter.

Consider adding a comment above the disabledFeatures property to explicitly state that it's the new recommended way to disable specific features, including those previously controlled by the legacy properties. This would further emphasize the transition to the new system.

docs/docs/data/create.tsx (3)

378-378: Clarify roles in 'deleteChatMessage' description

Consider clarifying "moderators or owner" to "moderators or the owner" for better readability.

Apply this diff to improve clarity:

- <b>Delete Chat Message (moderators or owner)</b>
+ <b>Delete Chat Message (moderators or the owner)</b>

382-382: Clarify ownership in 'editChatMessage' description

Consider changing "only owner" to "only the owner" to enhance clarity.

Apply this diff to improve clarity:

- <b>Edit Chat Message (only owner)</b>
+ <b>Edit Chat Message (only the owner)</b>

392-392: Ensure consistent capitalization in 'chatMessageReactions' description

Capitalize "Chat Message" consistently.

Apply this diff to improve consistency:

- <b>Send Reactions to a chat message</b>
+ <b>Send Reactions to a Chat Message</b>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 62e2f39 and 599a0ab.

📒 Files selected for processing (8)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/DeleteGroupChatMessageReactionReqMsgHdlr.scala (2 hunks)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/DeleteGroupChatMessageReqMsgHdlr.scala (2 hunks)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/EditGroupChatMessageReqMsgHdlr.scala (2 hunks)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/GroupChat.scala (1 hunks)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/SendGroupChatMessageMsgHdlr.scala (3 hunks)
  • akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/SendGroupChatMessageReactionReqMsgHdlr.scala (2 hunks)
  • bigbluebutton-web/grails-app/conf/bigbluebutton.properties (1 hunks)
  • docs/docs/data/create.tsx (1 hunks)
🔇 Additional comments (11)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/SendGroupChatMessageReactionReqMsgHdlr.scala (1)

Line range hint 1-65: Overall, the changes look good and achieve the PR objectives.

The implementation successfully introduces the ability to disable chat message reactions, aligning with the PR's goal. The changes are focused, maintain consistency with existing code patterns, and do not introduce unnecessary complexity.

Key points:

  1. The new chatMessageReactionsDisabled variable correctly checks for the disabled feature.
  2. The conditional statement has been appropriately modified to incorporate the new check.

The suggested minor improvements (extracting the feature name to a constant and breaking down the complex condition) would further enhance code readability and maintainability.

akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/DeleteGroupChatMessageReactionReqMsgHdlr.scala (1)

Line range hint 1-65: Overall implementation looks good.

The changes in this file successfully implement the ability to disable the chat message reactions feature, aligning well with the PR objectives. The implementation is consistent with existing patterns and maintains the overall structure and logic of the code.

A few minor suggestions for improvement have been made, but these are not critical for the functionality. Great job on implementing this feature!

akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/DeleteGroupChatMessageReqMsgHdlr.scala (2)

16-16: LGTM: New variable for disabling delete chat message feature.

The addition of deleteChatMessageDisabled aligns well with the PR objectives. It correctly checks the disabledFeatures property and follows the existing naming convention.


Line range hint 1-78: Implementation successfully adds delete chat message disabling feature.

The changes effectively implement the ability to disable the delete chat message feature, aligning well with the PR objectives. The implementation is consistent with existing code patterns and introduces no apparent security issues or logical errors.

To ensure consistent implementation across the codebase, let's verify the usage of the disabledFeatures property:

This verification will help ensure that the disabledFeatures property is used consistently across the codebase and that similar implementations are applied to other relevant message handlers.

✅ Verification successful

✅ Verification Successful: Delete Group Chat Message Disable Feature Confirmed

The implementation effectively adds the delete chat message disabling feature and aligns consistently with the existing usage of the disabledFeatures property across the codebase. No issues were identified during the verification process.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `disabledFeatures` property across the codebase

# Test 1: Check for other usages of `disabledFeatures`
echo "Checking for other usages of disabledFeatures:"
rg --type scala "disabledFeatures" -g '!DeleteGroupChatMessageReqMsgHdlr.scala'

# Test 2: Check for similar implementations in other message handlers
echo "Checking for similar implementations in other message handlers:"
rg --type scala "val \w+Disabled: Boolean = liveMeeting\.props\.meetingProp\.disabledFeatures\.contains\(" -g '*MsgHdlr.scala'

Length of output: 11537

akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/SendGroupChatMessageMsgHdlr.scala (4)

3-3: LGTM: Import statement cleanup

The modification to the import statement removes redundancy and improves code clarity by importing only the necessary method.


28-28: LGTM: New variable to check for disabled reply feature

The addition of replyChatMessageDisabled aligns with the PR objective of allowing specific chat features to be disabled. The variable name is clear, and the implementation correctly uses the disabledFeatures property of the meeting.


77-83: LGTM: Implemented logic to disable reply feature

The introduction of groupChatMsgReceived with conditional logic to clear replyToMessageId when the reply feature is disabled is well-implemented. It aligns with the PR objective and maintains immutability by using the copy method.


85-85: LGTM: Updated gcMessage construction

The modification to use groupChatMsgReceived instead of msg.body.msg in the gcMessage construction ensures that the potentially modified message (with cleared replyToMessageId) is correctly propagated. This change is consistent with the new feature disabling functionality.

akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/groupchats/GroupChat.scala (1)

23-26: Approved: Method simplification, but needs clarification

The changes to toGroupChatMessage method simplify its signature and ensure consistent use of metadata from the original message. This is a good improvement for maintainability.

However, I have a few points to address:

  1. Could you clarify how this change relates to the PR objective of introducing a disabledFeatures parameter? It's not immediately clear from this modification alone.

  2. Consider adding a comment to explain the reasoning behind this change, especially if it's a prerequisite for the feature disabling functionality.

To ensure this change doesn't break existing functionality, please run the following verification script:

bigbluebutton-web/grails-app/conf/bigbluebutton.properties (2)

456-457: Update to disabledFeatures property aligns with PR objectives

The changes to the disabledFeatures property now include the new chat features mentioned in the PR objectives:

  • deleteChatMessage
  • editChatMessage
  • replyChatMessage
  • chatMessageReactions

This update correctly implements the ability to disable these new chat functionalities as described in the PR summary.


Line range hint 456-474: Summary: Successful implementation of disabledFeatures with clear migration path

The changes in this file successfully achieve the PR's objective of introducing the disabledFeatures parameter to allow disabling of specific new chat functionalities. The implementation is clean and well-documented, with the following key points:

  1. The disabledFeatures property now includes options for the new chat features.
  2. Legacy properties are clearly marked as deprecated, with guidance on using the new disabledFeatures property instead.
  3. The allowDuplicateExtUserid property is correctly marked as legacy, with a reference to the new maxUserConcurrentAccesses property.

These changes provide a clear migration path for users transitioning from the old configuration to the new one, while maintaining backward compatibility. The implementation is robust and aligns perfectly with the PR objectives.

Comment thread docs/docs/data/create.tsx Resolved
Comment thread docs/docs/data/create.tsx Outdated
<li>
<code className="language-plaintext highlighter-rouge">
replyChatMessage
</code> - <b>Reply a Chat Message</b>

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.

⚠️ Potential issue

Fix grammatical error in 'replyChatMessage' description

Change "Reply a Chat Message" to "Reply to a Chat Message" for correct grammar.

Apply this diff to fix the grammatical error:

- <b>Reply a Chat Message</b>
+ <b>Reply to a Chat Message</b>
📝 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
</code> - <b>Reply a Chat Message</b>
</code> - <b>Reply to a Chat Message</b>

# Available options:
# chat, sharedNotes, polls, screenshare, externalVideos, layouts, captions, liveTranscription,
# sharedNotes, polls, screenshare, externalVideos, layouts, captions, liveTranscription,
# chat, deleteChatMessage, editChatMessage, replyChatMessage, chatMessageReactions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please sort alphabetically, possibly each item on new line 🙏

Comment thread docs/docs/data/create.tsx Outdated
<>
List (comma-separated) of features to disable in a particular meeting. (added 2.5)
<br /><br />
Available options to disable:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very much in favor of this suggestion. Thanks, Bunny!

Comment thread docs/docs/data/create.tsx Outdated
<li>
<code className="language-plaintext highlighter-rouge">
breakoutRooms
</code> - <b>Breakout Rooms</b>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@antobinary

Copy link
Copy Markdown
Member

Actually, I think it will be best if we don't yet document in
api.md
create.tsx
bigbluebutton.properties

We should wait until we can support these in recording #21356 , playback, (ideally testing too)

@sonarqubecloud

sonarqubecloud Bot commented Oct 4, 2024

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
20.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@gustavotrott

Copy link
Copy Markdown
Contributor Author

Actually, I think it will be best if we don't yet document in api.md create.tsx bigbluebutton.properties

We should wait until we can support these in recording #21356 , playback, (ideally testing too)

I reverted all documentations for now!

@gustavotrott

Copy link
Copy Markdown
Contributor Author

@JoVictorNunes please make the frontend respect these new disabledFeatures options! I implemented only the backend portion.

@github-actions

github-actions Bot commented Oct 4, 2024

Copy link
Copy Markdown

Automated tests Summary

✅ All the CI tests have passed!

@antobinary antobinary left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

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.

2 participants