Repository navigation
refactor (gql-server): Rename user_camera prop from focused to showAsContent - #21340
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
|
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Outside diff range and nitpick comments (9)
bbb-graphql-server/metadata/databases/BigBlueButton/tables/public_v_user_camera.yaml (1)
Line range hint
5-7: Consider enhancing column configurationWhile the primary change has been implemented correctly, you might want to consider the following improvements:
- Add metadata for the
showAsContentcolumn in thecolumn_configsection. This could include description, type, or other relevant information.- If a custom name is needed for the
showAsContentcolumn in the GraphQL API, you can define it in thecustom_column_namessection.These additions could enhance the API documentation and usability. Here's an example of how you might implement these suggestions:
configuration: column_config: showAsContent: description: "Indicates whether the camera should be shown as content" type: "boolean" custom_column_names: showAsContent: "displayAsMainContent"akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserCameraDAO.scala (1)
43-51: LGTM: NewupdateShowAsContentmethod addedThe new
updateShowAsContentmethod is a valuable addition that aligns with the PR objectives. It provides a way to update the renamedshowAsContentproperty for a specific meeting and stream ID.The method is well-structured and consistent with other DAO methods. However, consider adding error handling or logging to handle cases where the update might fail or affect an unexpected number of rows.
Consider adding error handling or logging, for example:
def updateShowAsContent(meetingId: String, streamId: String, showAsContent: Boolean) = { DatabaseConnection.enqueue( TableQuery[UserCameraDbTableDef] .filter(_.meetingId === meetingId) .filter(_.streamId === streamId) .map(cam => cam.showAsContent) .update(showAsContent) ).map { updatedRows => if (updatedRows == 0) { logger.warn(s"No rows updated for meetingId: $meetingId, streamId: $streamId") } else if (updatedRows > 1) { logger.warn(s"Multiple rows ($updatedRows) updated for meetingId: $meetingId, streamId: $streamId") } updatedRows } }This addition would provide more visibility into the update operation's results.
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/webcam/UserBroadcastCamStartMsgHdlr.scala (1)
49-50: Approved: Renaming improves clarity. Consider updating the comment.The renaming of
startFocusedtostartAsContentandfocusedtoshowAsContentin theWebcamStreamconstructor aligns well with the PR objectives. This change improves the clarity of the code by using more descriptive names that better reflect the functionality.Consider adding a brief comment explaining the
startAsContentlogic, such as:// Determine if the webcam should be shown as content based on content type and presenter status val startAsContent = msg.body.contentType == "screenshare" && userIsPresenterThis would further enhance code readability and maintainability.
bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/WebcamsMsgs.scala (1)
190-194: LGTM! Consider adding a brief comment for thesetByfield.The new
SetCamShowAsContentReqMsgaligns well with the PR objectives and maintains consistency with other message definitions in the file. The renaming fromfocusedtoshowAsContentimproves clarity.Consider adding a brief comment explaining the purpose of the
setByfield in theSetCamShowAsContentReqMsgBodycase class, as it's not mentioned in the PR objectives:case class SetCamShowAsContentReqMsgBody( streamId: String, showAsContent: Boolean, setBy: String // Identifier of the user who initiated this change )bbb-graphql-server/metadata/actions.graphql (1)
66-71: LGTM! Consider adding a brief description comment.The new
cameraSetShowAsContentmutation is well-structured and aligns perfectly with the PR objectives. The naming, parameter types, and return type are all appropriate and consistent with the existing codebase.To improve documentation, consider adding a brief description comment above the mutation, explaining its purpose and when it should be used. For example:
# Sets whether a camera stream should be shown as content. # Only applicable for the presenter role when contentType is 'screenshare'. type Mutation { cameraSetShowAsContent( streamId: String! showAsContent: Boolean! ): Boolean }akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala (1)
134-135: LGTM! Consider grouping related message handlers.The addition of
SetCamShowAsContentReqMsg.NAMEcase is correct and aligns with the PR objectives. The implementation follows the established pattern in the file.As a minor suggestion for future improvements, consider grouping related message handlers together. For instance, you could move this new case next to other camera-related message handlers for better code organization.
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala (1)
728-730: LGTM! Consider grouping webcam-related messages.The implementation for handling the new
SetCamShowAsContentReqMsglooks good and consistent with other webcam-related message handlers. It correctly processes the message and updates the user's last activity.Consider grouping all webcam-related message handlers together for better code organization. You could move this new handler next to other webcam-specific handlers like
UserBroadcastCamStartMsgandUserBroadcastCamStopMsg.akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/webcam/SetCamShowAsContentReqMsgHdlr.scala (2)
32-32: Clarify the permission check logicThe variable
userIsPresenteris determined by negating the result ofpermissionFailed, which might be less intuitive. Consider renaming the variable tohasPresenterPermissionsand adjusting the logic for better readability.Apply this diff to enhance clarity:
- val userIsPresenter = !permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId) + val hasPresenterPermissions = permissionFailed(PermissionCheck.GUEST_LEVEL, PermissionCheck.PRESENTER_LEVEL, liveMeeting.users2x, msg.header.userId) == false
19-61: Enhance error handling and loggingAdding logging statements for key actions and error conditions can facilitate easier debugging and monitoring. Consider logging when permission checks fail, when webcams are not found, and when significant actions are performed.
Example enhancement:
+ log.debug(s"Handling SetCamShowAsContentReqMsg for user ${msg.header.userId} in meeting $meetingId.") val hasPresenterPermissions = !permissionFailed(...) if (!hasPresenterPermissions) { // Existing logic + log.warning(s"Permission denied for user ${msg.header.userId} in meeting $meetingId.") } else { for { webcam <- Webcams.findWithStreamId(...) } yield { if (webcam.contentType != "screenshare") { // Existing logic + log.info(s"User ${msg.header.userId} attempted to set non-screenshare content in meeting $meetingId.") } else { // Existing logic + log.info(s"User ${msg.header.userId} set webcam ${webcam.streamId} as content in meeting $meetingId.") } } + }.getOrElse { + // Handle webcam not found + } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (15)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/webcam/SetCamShowAsContentReqMsgHdlr.scala (1 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/webcam/UserBroadcastCamStartMsgHdlr.scala (1 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/webcam/WebcamApp2x.scala (1 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserCameraDAO.scala (2 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Webcams.scala (1 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ReceivedJsonMsgHandlerActor.scala (1 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/MeetingActor.scala (1 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/AnalyticsActor.scala (1 hunks)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scala (1 hunks)
- bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/WebcamsMsgs.scala (1 hunks)
- bbb-graphql-actions/src/actions/cameraSetShowAsContent.ts (2 hunks)
- bbb-graphql-server/bbb_schema.sql (1 hunks)
- bbb-graphql-server/metadata/actions.graphql (1 hunks)
- bbb-graphql-server/metadata/actions.yaml (1 hunks)
- bbb-graphql-server/metadata/databases/BigBlueButton/tables/public_v_user_camera.yaml (1 hunks)
🔇 Additional comments (17)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/webcam/WebcamApp2x.scala (1)
16-17: LGTM: Addition ofSetCamShowAsContentReqMsgHdlrtrait aligns with PR objectives.The inclusion of the
SetCamShowAsContentReqMsgHdlrtrait is consistent with the PR's goal of renaming thefocusedproperty toshowAsContent. This change likely implements the handler for the newcameraSetShowAsContentmutation mentioned in the PR objectives, enhancing theWebcamApp2xclass's ability to manage webcam content display.bbb-graphql-actions/src/actions/cameraSetShowAsContent.ts (4)
9-9: LGTM: Input validation updated correctlyThe input validation has been properly updated to check for 'showAsContent' instead of 'focused'. This change aligns with the PR objective and maintains the correct type (boolean) and required status.
28-28: LGTM: Message body updated correctlyThe message body has been correctly updated to use 'showAsContent' instead of 'focused'. This change is consistent with the PR objective and maintains the alignment between the input parameter and the message body.
Line range hint
1-32: Overall: Changes are consistent and align with PR objectivesThe renaming from 'focused' to 'showAsContent' has been consistently applied throughout the file. This includes updates to:
- Input validation
- Event name
- Message body
These changes align well with the PR objectives and maintain the overall functionality of the
buildRedisMessagefunction.🧰 Tools
🪛 Biome
[error] 15-15: Don't use 'String' as a type.
Use lowercase primitives for consistency.
Safe fix: Use 'string' instead(lint/complexity/noBannedTypes)
[error] 16-16: Don't use 'String' as a type.
Use lowercase primitives for consistency.
Safe fix: Use 'string' instead(lint/complexity/noBannedTypes)
13-13: LGTM: Event name updated correctlyThe event name has been appropriately updated to 'SetCamShowAsContentReqMsg', which is consistent with the renaming from 'focused' to 'showAsContent'.
To ensure consistency across the codebase, please verify the usage of this new event name:
✅ Verification successful
Verification Successful: Event name updated consistently across the codebase
The usage of
SetCamShowAsContentReqMsghas been verified across the codebase, andSetCamFocusStateReqMsgno longer appears.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the new event name across the codebase # Test: Search for both old and new event names echo "Occurrences of old event name (should be 0):" rg "SetCamFocusStateReqMsg" echo "Occurrences of new event name:" rg "SetCamShowAsContentReqMsg"Length of output: 1886
bbb-graphql-server/metadata/databases/BigBlueButton/tables/public_v_user_camera.yaml (1)
33-33: LGTM: Column name updated as per PR objectives.The change from
focusedtoshowAsContentin theselect_permissionsfor thebbb_clientrole is correctly implemented and aligns with the PR objectives. This update enhances clarity in the GraphQL API by providing a more descriptive name for the property.To ensure consistency across the codebase, let's verify if this change has been applied everywhere it's needed:
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/UserCameraDAO.scala (3)
12-12: LGTM: RenamingfocusedtoshowAsContentimproves clarityThis change aligns well with the PR objectives. The new name
showAsContentis more descriptive and better reflects the property's purpose in the context of user camera functionality.
17-17: LGTM: Database schema updated consistently with model changesThe changes in the
UserCameraDbTableDefclass correctly reflect the renaming offocusedtoshowAsContent. This ensures consistency between the Scala model and the database schema, which is crucial for proper data persistence and retrieval.Also applies to: 23-23
37-37: LGTM: Insert method updated consistently with model changesThe
insertmethod has been correctly updated to useshowAsContentinstead offocusedwhen creating a newUserCameraDbModelinstance. This change maintains consistency with the earlier modifications to the model and table definition.akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Webcams.scala (2)
Line range hint
1-106: Ensure consistency throughout the fileWhile the visible parts of the
Webcamsobject andWebcamsclass don't directly reference the renamed field, it's important to verify that there are no hidden usages of the oldfocusedfield name within method implementations.Please run the following script to check for any usage of the old field name within this file:
#!/bin/bash # Description: Check for any usage of 'focused' field in the Webcams.scala file # Test: Search for 'focused' in Webcams.scala. Expect: No occurrences related to WebcamStream. rg --type scala 'focused' akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Webcams.scala -C 5If any occurrences are found, please update them to use the new
showAsContentfield name.
101-106: LGTM! Verify usage of the new field name throughout the codebase.The change from
focusedtoshowAsContentin theWebcamStreamcase class aligns with the PR objectives. The field type remains Boolean, and its position in the case class definition is appropriate.To ensure this change doesn't introduce any issues, please run the following script to check for any remaining usage of the old field name:
Also, verify that all usages of
WebcamStreamhave been updated to use the new field name:akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/testdata/FakeUserGenerator.scala (1)
118-118: LGTM! Verify usage in tests.The renaming of
focusedtoshowAsContentin theWebcamStreaminstantiation aligns with the PR objectives and improves clarity. The default value offalseis appropriate for a test data generator.To ensure consistency, please verify that this change is reflected in any tests using
FakeUserGenerator.createFakeWebcamStreamFor. Run the following script to check for potential usage:bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/WebcamsMsgs.scala (1)
196-201: LGTM! Verify the intended usage of this event message.The new
SetCamShowAsContentEvtMsgis a logical addition to complement the request message and follows the established patterns in the file. The structure and naming are consistent with other messages.Could you confirm that this event message is intended to be broadcasted to all clients when a camera's
showAsContentstate changes? If so, consider adding a brief comment to clarify its purpose:/** * Sent to all clients when a camera's showAsContent state changes. */ object SetCamShowAsContentEvtMsg { val NAME = "SetCamShowAsContentEvtMsg" }To verify the usage of this new event message, you can run the following script:
This will help ensure that the new event message is being used as intended in the codebase.
✅ Verification successful
Verified the usage of
SetCamShowAsContentEvtMsgis correct and as intended.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for the usage of SetCamShowAsContentEvtMsg in the codebase # Search for SetCamShowAsContentEvtMsg usage echo "Searching for SetCamShowAsContentEvtMsg usage:" rg "SetCamShowAsContentEvtMsg" --type scala -C 3Length of output: 3071
bbb-graphql-server/metadata/actions.yaml (1)
Line range hint
1-73: Summary: New action added successfullyThe changes in this file are minimal and focused. The new
cameraSetShowAsContentaction has been added successfully, following the established patterns in the file. This addition aligns with the PR objectives to rename the 'focused' property to 'showAsContent' in the GraphQL API.No other parts of the file were modified, maintaining the integrity of the existing actions. The change enhances the API's clarity by providing a more descriptive name for the camera-related functionality.
bbb-graphql-server/bbb_schema.sql (3)
642-642: RenamefocusedtoshowAsContentinuser_cameratableThe column
showAsContenthas been added to theuser_cameratable, replacing the previousfocusedcolumn. This change aligns with the PR objectives to rename thefocusedproperty toshowAsContent.
647-647: Update index to useshowAsContentinstead offocusedThe index
idx_user_camera_meeting_contentTypehas been updated to include the newshowAsContentcolumn instead of the previousfocusedcolumn. This change is consistent with the column renaming and ensures that the index remains relevant for query optimization.
642-647: Verify impact on related database objectsThe changes to rename
focusedtoshowAsContentin theuser_cameratable and its index have been implemented correctly. However, it's important to ensure that all related database objects (such as views, functions, or triggers) that might reference the oldfocusedcolumn are also updated accordingly.To check for any remaining references to the old
focusedcolumn, please run the following script:If any results are returned, please update the corresponding objects to use
showAsContentinstead offocused.
| case m: TransferUserToVoiceConfSysMsg => logMessage(msg) | ||
| case m: UserBroadcastCamStartMsg => logMessage(msg) | ||
| case m: UserBroadcastCamStopMsg => logMessage(msg) | ||
| case m: SetCamShowAsContentReqMsg => logMessage(msg) |
There was a problem hiding this comment.
💡 Codebase verification
Issues Found: Incomplete Renaming of focused Property
The focused property related to cameras is still present in several areas of the codebase. This suggests that the renaming to showAsContent might be incomplete, which could lead to inconsistencies and potential bugs.
Affected Files:
bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/LayoutMsgs.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/db/LayoutDAO.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/layout/BroadcastLayoutMsgHdlr.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Layouts.scala
Please ensure that all instances of the focused property are updated to showAsContent to align with the PR objectives and maintain consistency across the codebase.
🔗 Analysis chain
LGTM: New message handler added correctly.
The addition of the SetCamShowAsContentReqMsg case is consistent with the PR objectives and follows the existing pattern for message handling in this class. This change ensures that the new message type will be properly logged, maintaining consistency with other camera-related events.
To ensure consistency across the codebase, let's verify the usage of SetCamShowAsContentReqMsg:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the usage of SetCamShowAsContentReqMsg across the codebase
# Search for SetCamShowAsContentReqMsg usage
echo "Searching for SetCamShowAsContentReqMsg usage:"
rg --type scala "SetCamShowAsContentReqMsg"
# Search for any remaining instances of 'focused' property related to cameras
echo "Searching for any remaining 'focused' property related to cameras:"
rg --type scala "focused.*camera" -i
Length of output: 3777
| - name: cameraSetShowAsContent | ||
| definition: | ||
| kind: synchronous | ||
| handler: '{{HASURA_BBB_GRAPHQL_ACTIONS_ADAPTER_URL}}' | ||
| permissions: | ||
| - role: bbb_client |
There was a problem hiding this comment.
💡 Codebase verification
Issues Found: 'focused' property is still referenced in multiple locations
The search revealed several remaining references to the focused property related to camera functionalities:
bigbluebutton-html5/imports/ui/components/webcam/component.tsxbigbluebutton-html5/imports/ui/components/video-provider/video-list/video-list-item/component.tsxbigbluebutton-html5/imports/ui/components/layout/enums.jsbbb-graphql-actions/src/actions/meetingLayoutSetProps.ts- (and others as listed in the shell script output)
Please ensure that all instances of the focused property are appropriately renamed to maintain consistency and avoid potential conflicts.
🔗 Analysis chain
LGTM: New action cameraSetShowAsContent added correctly
The new action cameraSetShowAsContent has been added correctly and follows the established pattern in the file. It aligns with the PR objectives to rename the 'focused' property to 'showAsContent'. The action definition is consistent with other actions in terms of structure, handler, and permissions.
To ensure consistency across the codebase, let's verify if there are any remaining references to the old 'focused' property:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining 'focused' references related to camera or user camera
rg -i 'focused.*camera|camera.*focused' --type yaml --type typescript --type javascript
Length of output: 124
Script:
#!/bin/bash
# Search for any remaining 'focused' references related to camera or user camera
rg -i 'focused.*camera|camera.*focused' --type yaml --type ts --type js
Length of output: 4526
| def broadcastEvent(meetingId: String, userId: String, streamId: String, showAsContent: Boolean, setBy: String): Unit = { | ||
| val routing = Routing.addMsgToClientRouting(MessageTypes.BROADCAST_TO_MEETING, meetingId, userId) | ||
| val envelope = BbbCoreEnvelope(SetCamShowAsContentEvtMsg.NAME, routing) | ||
| val header = BbbClientMsgHeader(SetCamShowAsContentEvtMsg.NAME, meetingId, userId) | ||
| val body = SetCamShowAsContentEvtMsgBody(streamId, showAsContent, setBy) | ||
| val event = SetCamShowAsContentEvtMsg(header, body) | ||
| val msgEvent = BbbCommonEnvCoreMsg(envelope, event) | ||
|
|
||
| bus.outGW.send(msgEvent) | ||
| } | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion
Extract message broadcasting logic to a shared utility
The broadcastEvent function constructs and sends a message, which is a pattern likely used elsewhere. Consider extracting this logic into a shared utility or helper method to promote code reuse and simplify maintenance.
| broadcastEvent(meetingId, msg.header.userId, webcam.streamId, msg.body.showAsContent, msg.body.setBy) | ||
| UserCameraDAO.updateShowAsContent(meetingId, webcam.streamId, msg.body.showAsContent) |
There was a problem hiding this comment.
Update the data store before broadcasting the event
Consider updating UserCameraDAO before broadcasting the event to ensure that the state is consistent when clients receive the update. This helps prevent clients from reacting to an event that hasn't been persisted yet.
Apply this diff to reorder the operations:
} else {
- broadcastEvent(meetingId, msg.header.userId, webcam.streamId, msg.body.showAsContent, msg.body.setBy)
UserCameraDAO.updateShowAsContent(meetingId, webcam.streamId, msg.body.showAsContent)
+ broadcastEvent(meetingId, msg.header.userId, webcam.streamId, msg.body.showAsContent, msg.body.setBy)
}📝 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.
| broadcastEvent(meetingId, msg.header.userId, webcam.streamId, msg.body.showAsContent, msg.body.setBy) | |
| UserCameraDAO.updateShowAsContent(meetingId, webcam.streamId, msg.body.showAsContent) | |
| UserCameraDAO.updateShowAsContent(meetingId, webcam.streamId, msg.body.showAsContent) | |
| broadcastEvent(meetingId, msg.header.userId, webcam.streamId, msg.body.showAsContent, msg.body.setBy) |
| if (!userIsPresenter) { | ||
| val reason = "No permission to set showAsContent for camera." | ||
| PermissionCheck.ejectUserForFailedPermission( | ||
| meetingId, | ||
| msg.header.userId, | ||
| reason, | ||
| bus.outGW, | ||
| liveMeeting | ||
| ) | ||
| } else { |
There was a problem hiding this comment.
Avoid ejecting users for insufficient permissions
Ejecting a user due to insufficient permissions might be too severe. Instead, consider sending an error message informing the user that they lack the necessary permissions to perform this action.
Apply this diff to modify the behavior:
- val reason = "No permission to set showAsContent for camera."
- PermissionCheck.ejectUserForFailedPermission(
- meetingId,
- msg.header.userId,
- reason,
- bus.outGW,
- liveMeeting
- )
+ val reason = "You do not have permission to set showAsContent for the camera."
+ PermissionCheck.sendPermissionError(
+ meetingId,
+ msg.header.userId,
+ reason,
+ bus.outGW
+ )
+ // Optionally, log the permission denial for auditing purposes
+ log.warning(s"User ${msg.header.userId} attempted to set showAsContent without sufficient permissions in meeting $meetingId.")
}📝 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.
| if (!userIsPresenter) { | |
| val reason = "No permission to set showAsContent for camera." | |
| PermissionCheck.ejectUserForFailedPermission( | |
| meetingId, | |
| msg.header.userId, | |
| reason, | |
| bus.outGW, | |
| liveMeeting | |
| ) | |
| } else { | |
| if (!userIsPresenter) { | |
| val reason = "You do not have permission to set showAsContent for the camera." | |
| PermissionCheck.sendPermissionError( | |
| meetingId, | |
| msg.header.userId, | |
| reason, | |
| bus.outGW | |
| ) | |
| // Optionally, log the permission denial for auditing purposes | |
| log.warning(s"User ${msg.header.userId} attempted to set showAsContent without sufficient permissions in meeting $meetingId.") | |
| } else { |
| if (webcam.contentType != "screenshare") { | ||
| val reason = "Only screenshare can be set as content." | ||
| PermissionCheck.ejectUserForFailedPermission( | ||
| meetingId, | ||
| msg.header.userId, | ||
| reason, | ||
| bus.outGW, | ||
| liveMeeting | ||
| ) | ||
| } else { |
There was a problem hiding this comment.
Avoid ejecting users when content type does not match
Ejecting a user because the webcam's contentType is not "screenshare" may be excessive. Instead, inform the user that only screenshares can be set as content and prevent the action without ejecting them.
Apply this diff to adjust the response:
if (webcam.contentType != "screenshare") {
- val reason = "Only screenshare can be set as content."
- PermissionCheck.ejectUserForFailedPermission(
- meetingId,
- msg.header.userId,
- reason,
- bus.outGW,
- liveMeeting
- )
+ val reason = "Only screenshare streams can be set as content."
+ PermissionCheck.sendActionError(
+ meetingId,
+ msg.header.userId,
+ reason,
+ bus.outGW
+ )
+ // Optionally, log the action denial
+ log.info(s"User ${msg.header.userId} attempted to set a non-screenshare stream as content in meeting $meetingId.")
} else {
// Existing logic
}📝 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.
| if (webcam.contentType != "screenshare") { | |
| val reason = "Only screenshare can be set as content." | |
| PermissionCheck.ejectUserForFailedPermission( | |
| meetingId, | |
| msg.header.userId, | |
| reason, | |
| bus.outGW, | |
| liveMeeting | |
| ) | |
| } else { | |
| if (webcam.contentType != "screenshare") { | |
| val reason = "Only screenshare streams can be set as content." | |
| PermissionCheck.sendActionError( | |
| meetingId, | |
| msg.header.userId, | |
| reason, | |
| bus.outGW | |
| ) | |
| // Optionally, log the action denial | |
| log.info(s"User ${msg.header.userId} attempted to set a non-screenshare stream as content in meeting $meetingId.") | |
| } else { |
| for { | ||
| webcam <- Webcams.findWithStreamId(liveMeeting.webcams, msg.body.streamId) | ||
| } yield { | ||
| if (webcam.contentType != "screenshare") { | ||
| val reason = "Only screenshare can be set as content." | ||
| PermissionCheck.ejectUserForFailedPermission( | ||
| meetingId, | ||
| msg.header.userId, | ||
| reason, | ||
| bus.outGW, | ||
| liveMeeting | ||
| ) | ||
| } else { | ||
| broadcastEvent(meetingId, msg.header.userId, webcam.streamId, msg.body.showAsContent, msg.body.setBy) | ||
| UserCameraDAO.updateShowAsContent(meetingId, webcam.streamId, msg.body.showAsContent) | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Handle the case when the webcam is not found
If Webcams.findWithStreamId returns None, the code silently does nothing. This could lead to confusion. Consider handling this scenario by informing the user that the specified webcam stream was not found.
Apply this diff to handle the missing webcam:
for {
webcam <- Webcams.findWithStreamId(liveMeeting.webcams, msg.body.streamId)
} yield {
if (webcam.contentType != "screenshare") {
// Existing logic
} else {
// Existing logic
}
+ }
+ }.getOrElse {
+ val reason = s"Webcam stream with ID ${msg.body.streamId} was not found."
+ PermissionCheck.sendNotFoundError(
+ meetingId,
+ msg.header.userId,
+ reason,
+ bus.outGW
+ )
+ // Optionally, log the missing webcam for debugging purposes
+ log.warning(s"Webcam stream not found for stream ID ${msg.body.streamId} in meeting $meetingId.")
}Committable suggestion was skipped due to low confidence.
Automated tests Summary✅ All the CI tests have passed! |


presenterandcontentType='screenshare')Related #21303