Repository navigation
fix(breakouts): user id handling - #24986
Conversation
WalkthroughReplaces per-type breakout-room lookup helpers with shared utilities in a new HandlerHelpers trait. HandlerHelpers adds methods to extract a main-room internal user id from a breakout external id, match by that id across generic user vectors, and provide overloads for Users2x and RegisteredUsers. The trait is mixed into BreakoutRoomUsersUpdateMsgHdlr, which now calls findUserInMainRoom(...) and renames resolved variables to parentMeetingUser. The now-unused findWithBreakoutRoomId helpers were removed from Users2x and RegisteredUsers. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala`:
- Around line 25-37: The lookup strips the breakout suffix but still compares to
internal ids (using _.intId / _.id), so users whose breakout URL was built from
their external id are missed; update matchByBreakoutRoomExtUserId to compare the
extracted main-room id against the user’s external id by changing the extractor
passed from _.intId / _.id to the users' external-id accessor (e.g., _.extId or
_.externalId) and/or rename the extractor parameter to make it clear it should
return the id used in breakout URLs; adjust the two callers
findUserInMainRoom(Users2x, ...) and findUserInMainRoom(RegisteredUsers, ...) to
pass the correct external-id accessor (instead of _.intId / _.id) so the
comparison matches breakoutRoomExtUserId after stripping.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 79930866-053a-46e2-918b-720abda656c0
📒 Files selected for processing (4)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/BreakoutRoomUsersUpdateMsgHdlr.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala
💤 Files with no reviewable changes (2)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala
| def matchByBreakoutRoomExtUserId[T](users: Vector[T], breakoutRoomExtUserId: String)(extractInternalUserId: T => String): Option[T] = { | ||
| // The external id of the user in the breakout is the internal id of the user in the main room appended by the room sequence | ||
| val mainRoomInternalUserId = extractMainRoomInternalUserId(breakoutRoomExtUserId) | ||
| users.find(user => extractInternalUserId(user) == mainRoomInternalUserId) | ||
| } | ||
|
|
||
| def findUserInMainRoom(users: Users2x, breakoutRoomExtUserId: String): Option[UserState] = { | ||
| matchByBreakoutRoomExtUserId(Users2x.findAll(users), breakoutRoomExtUserId)(_.intId) | ||
| } | ||
|
|
||
| def findUserInMainRoom(users: RegisteredUsers, breakoutRoomExtUserId: String): Option[RegisteredUser] = { | ||
| matchByBreakoutRoomExtUserId(RegisteredUsers.findAll(users), breakoutRoomExtUserId)(_.id) | ||
| } |
There was a problem hiding this comment.
Match the lookup key to the breakout ID source.
findUserInMainRoom strips the breakout suffix, but it still compares against intId / id. If breakout URLs are now built from external IDs, this lookup will return None for users whose external and internal IDs differ, and the parent-room inactivity / breakout bookkeeping in BreakoutRoomUsersUpdateMsgHdlr will silently skip them.
Proposed fix
def findUserInMainRoom(users: Users2x, breakoutRoomExtUserId: String): Option[UserState] = {
- matchByBreakoutRoomExtUserId(Users2x.findAll(users), breakoutRoomExtUserId)(_.intId)
+ matchByBreakoutRoomExtUserId(Users2x.findAll(users), breakoutRoomExtUserId)(_.extId)
}
def findUserInMainRoom(users: RegisteredUsers, breakoutRoomExtUserId: String): Option[RegisteredUser] = {
- matchByBreakoutRoomExtUserId(RegisteredUsers.findAll(users), breakoutRoomExtUserId)(_.id)
+ matchByBreakoutRoomExtUserId(RegisteredUsers.findAll(users), breakoutRoomExtUserId)(_.externId)
}📝 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 matchByBreakoutRoomExtUserId[T](users: Vector[T], breakoutRoomExtUserId: String)(extractInternalUserId: T => String): Option[T] = { | |
| // The external id of the user in the breakout is the internal id of the user in the main room appended by the room sequence | |
| val mainRoomInternalUserId = extractMainRoomInternalUserId(breakoutRoomExtUserId) | |
| users.find(user => extractInternalUserId(user) == mainRoomInternalUserId) | |
| } | |
| def findUserInMainRoom(users: Users2x, breakoutRoomExtUserId: String): Option[UserState] = { | |
| matchByBreakoutRoomExtUserId(Users2x.findAll(users), breakoutRoomExtUserId)(_.intId) | |
| } | |
| def findUserInMainRoom(users: RegisteredUsers, breakoutRoomExtUserId: String): Option[RegisteredUser] = { | |
| matchByBreakoutRoomExtUserId(RegisteredUsers.findAll(users), breakoutRoomExtUserId)(_.id) | |
| } | |
| def matchByBreakoutRoomExtUserId[T](users: Vector[T], breakoutRoomExtUserId: String)(extractInternalUserId: T => String): Option[T] = { | |
| // The external id of the user in the breakout is the internal id of the user in the main room appended by the room sequence | |
| val mainRoomInternalUserId = extractMainRoomInternalUserId(breakoutRoomExtUserId) | |
| users.find(user => extractInternalUserId(user) == mainRoomInternalUserId) | |
| } | |
| def findUserInMainRoom(users: Users2x, breakoutRoomExtUserId: String): Option[UserState] = { | |
| matchByBreakoutRoomExtUserId(Users2x.findAll(users), breakoutRoomExtUserId)(_.extId) | |
| } | |
| def findUserInMainRoom(users: RegisteredUsers, breakoutRoomExtUserId: String): Option[RegisteredUser] = { | |
| matchByBreakoutRoomExtUserId(RegisteredUsers.findAll(users), breakoutRoomExtUserId)(_.externId) | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala`
around lines 25 - 37, The lookup strips the breakout suffix but still compares
to internal ids (using _.intId / _.id), so users whose breakout URL was built
from their external id are missed; update matchByBreakoutRoomExtUserId to
compare the extracted main-room id against the user’s external id by changing
the extractor passed from _.intId / _.id to the users' external-id accessor
(e.g., _.extId or _.externalId) and/or rename the extractor parameter to make it
clear it should return the id used in breakout URLs; adjust the two callers
findUserInMainRoom(Users2x, ...) and findUserInMainRoom(RegisteredUsers, ...) to
pass the correct external-id accessor (instead of _.intId / _.id) so the
comparison matches breakoutRoomExtUserId after stripping.
There was a problem hiding this comment.
It was reverted, now the breakout user's extId is constructed from the main room user's intId, not from extId.
There was a problem hiding this comment.
@gustavotrott, thanks for the clarification! That makes sense — since the breakout room user's extId is {mainRoom.intId}-{roomNumber}, stripping the last segment correctly recovers the main room's intId, and comparing against _.intId / _.id is the right approach. My suggestion to switch to _.extId / _.externId was based on a wrong assumption. The current code is correct.
🐰 🔍 twitches nose thoughtfully
✏️ Learnings added
Learnt from: gustavotrott
Repo: bigbluebutton/bigbluebutton PR: 24986
File: akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala:25-37
Timestamp: 2026-05-06T12:43:30.037Z
Learning: In BigBlueButton (BBB), a breakout room user's external ID (`extId`) is constructed as `{mainRoomUser.intId}-{roomNumber}`. The `extractMainRoomInternalUserId` helper in `HandlerHelpers.scala` strips the last hyphen-separated segment to recover the main room's internal user ID (`intId`). Therefore, `findUserInMainRoom` correctly compares the extracted value against `_.intId` (for `Users2x`) and `_.id` (for `RegisteredUsers`), NOT against `_.extId` / `_.externId`.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
gustavotrott
left a comment
There was a problem hiding this comment.
In the PR description you mention that "The join URL now correctly uses the external user ID", but this was reverted in commit c39a014.
It's confusing. Please update the description to reflect the current state of the code and reference commits from this PR.
Breakout rooms build the user ID by appending `-<roomNumber>` to the external user ID. The previous extraction logic retrieved the original external ID by taking the first chunk of the hyphen-separated string. This caused issues in edge cases where users joined with prefixed external IDs. For example, `myprefix-w_r12ch33-1` was incorrectly extracted as `myprefix`. The extraction logic now removes only the last hyphen-separated segment, ensuring the original external user ID is preserved.
Extracts the duplicate code from RegisteredUsers and Users2x to a helper function declared in HandlerHelpers as suggested by @prlanzarin in the PR's review.
- Reverts the breakout room join url creation to use the user's internal id in the main room as the user's external id in the breakout room. - Adjusts the user matching logic to compare the correct fields and make the code more readable.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/BreakoutRoomUsersUpdateMsgHdlr.scala (1)
29-43: ⚡ Quick winDuplicate
findUserInMainRoom(liveMeeting.registeredUsers, ...)per user — merge the two for-comprehensions.Lines 29-36 and 38-43 each independently scan
liveMeeting.registeredUsersfor the samebreakoutRoomUser.extId. Combining them into a single for-comprehension eliminates the redundant lookup.♻️ Proposed refactor
- //Update lastBreakout in registeredUsers to avoid lose this info when the user leaves - for { - breakoutRoomUser <- updatedRoom.users - parentMeetingUser <- findUserInMainRoom(liveMeeting.registeredUsers, breakoutRoomUser.extId) - } yield { - if (room != null && (parentMeetingUser.lastBreakoutRoom == null || parentMeetingUser.lastBreakoutRoom.id != room.id)) { - RegisteredUsers.updateUserLastBreakoutRoom(liveMeeting.registeredUsers, parentMeetingUser, room) - } - } - - for { - breakoutRoomUser <- updatedRoom.users - parentMeetingUser <- findUserInMainRoom(liveMeeting.registeredUsers, breakoutRoomUser.extId) - } yield { - BreakoutRoomUserDAO.updateUserJoined(breakoutRoomUser, parentMeetingUser, updatedRoom) - } + //Update lastBreakout in registeredUsers to avoid lose this info when the user leaves + for { + breakoutRoomUser <- updatedRoom.users + parentMeetingUser <- findUserInMainRoom(liveMeeting.registeredUsers, breakoutRoomUser.extId) + } yield { + if (parentMeetingUser.lastBreakoutRoom == null || parentMeetingUser.lastBreakoutRoom.id != room.id) { + RegisteredUsers.updateUserLastBreakoutRoom(liveMeeting.registeredUsers, parentMeetingUser, room) + } + BreakoutRoomUserDAO.updateUserJoined(breakoutRoomUser, parentMeetingUser, updatedRoom) + }Note: The
room != nullguard is also dropped above —roomis extracted from amodel.find(...)Optionand is guaranteed non-null within the outer for-comprehension'syieldblock.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/BreakoutRoomUsersUpdateMsgHdlr.scala` around lines 29 - 43, Merge the two identical for-comprehensions into one inside BreakoutRoomUsersUpdateMsgHdlr: iterate updatedRoom.users and call findUserInMainRoom(liveMeeting.registeredUsers, breakoutRoomUser.extId) once per breakoutRoomUser, then inside the single body invoke RegisteredUsers.updateUserLastBreakoutRoom(liveMeeting.registeredUsers, parentMeetingUser, room) (respecting the existing guard logic or dropping the redundant room != null check if room is already an Option-derived value) and BreakoutRoomUserDAO.updateUserJoined(breakoutRoomUser, parentMeetingUser, updatedRoom); this removes the duplicate lookup and keeps both updates per user in one pass.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/BreakoutRoomUsersUpdateMsgHdlr.scala`:
- Around line 29-43: Merge the two identical for-comprehensions into one inside
BreakoutRoomUsersUpdateMsgHdlr: iterate updatedRoom.users and call
findUserInMainRoom(liveMeeting.registeredUsers, breakoutRoomUser.extId) once per
breakoutRoomUser, then inside the single body invoke
RegisteredUsers.updateUserLastBreakoutRoom(liveMeeting.registeredUsers,
parentMeetingUser, room) (respecting the existing guard logic or dropping the
redundant room != null check if room is already an Option-derived value) and
BreakoutRoomUserDAO.updateUserJoined(breakoutRoomUser, parentMeetingUser,
updatedRoom); this removes the duplicate lookup and keeps both updates per user
in one pass.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 45c4ddc9-ab98-4c6c-9c10-97ac670b89a7
📒 Files selected for processing (4)
akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/breakout/BreakoutRoomUsersUpdateMsgHdlr.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scalaakka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala
💤 Files with no reviewable changes (2)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/Users2x.scala
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala
🚧 Files skipped from review as they are similar to previous changes (1)
- akka-bbb-apps/src/main/scala/org/bigbluebutton/core/running/HandlerHelpers.scala
gustavotrott
left a comment
There was a problem hiding this comment.
LGTM, well done!
Let's wait for Automated Tests before merging.
✅ Automated tests have passed! |
44ed4c4
into
bigbluebutton:v3.0.x-develop



What does this PR do?
Breakout rooms build the user ID by appending
-<roomNumber>to the external user ID. The previous extraction logic retrieved the original external ID by taking the first chunk of the hyphen-separated string.This caused issues in edge cases where users joined with prefixed external IDs. For example,
myprefix-w_r12ch33-1was incorrectly extracted asmyprefix.The extraction logic now removes only the last hyphen-separated segment, ensuring the original external user ID is preserved.
Extracts the duplicate code from RegisteredUsers and Users2x to a helper function declared in HandlerHelpers as suggested by @prlanzarin in the PR's review.
Closes Issue(s)
Closes #24398