diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/EjectUserFromMeetingCmdMsgHdlr.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/EjectUserFromMeetingCmdMsgHdlr.scala index ff50cb5c7f..3d20465cf2 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/EjectUserFromMeetingCmdMsgHdlr.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/EjectUserFromMeetingCmdMsgHdlr.scala @@ -30,15 +30,29 @@ trait EjectUserFromMeetingCmdMsgHdlr extends RightsManagementTrait { val reason = "user ejected by another user" for { registeredUser <- RegisteredUsers.findWithUserId(userId, liveMeeting.registeredUsers) + ejectedByUser <- RegisteredUsers.findWithUserId(ejectedBy, liveMeeting.registeredUsers) } yield { - // User might have joined using multiple browsers. - // Hunt down all registered users based on extern userid and eject them all. - // ralam april 21, 2020 - RegisteredUsers.findAllWithExternUserId(registeredUser.externId, liveMeeting.registeredUsers) foreach { ru => - UsersApp.ejectUserFromMeeting(outGW, liveMeeting, ru.id, ejectedBy, reason, EjectReasonCode.EJECT_USER) + if (registeredUser.externId != ejectedByUser.externId) { + // Eject users + println("****************** User " + ejectedBy + " ejecting user " + userId) + // User might have joined using multiple browsers. + // Hunt down all registered users based on extern userid and eject them all. + // ralam april 21, 2020 + RegisteredUsers.findAllWithExternUserId(registeredUser.externId, liveMeeting.registeredUsers) foreach { ru => + println("****************** User " + ejectedBy + " ejecting other user " + ru.id) + UsersApp.ejectUserFromMeeting(outGW, liveMeeting, ru.id, ejectedBy, reason, EjectReasonCode.EJECT_USER) + // send a system message to force disconnection + Sender.sendDisconnectClientSysMsg(meetingId, ru.id, ejectedBy, EjectReasonCode.EJECT_USER, outGW) + } + } else { + // User is ejecting self, so just eject this userid not all sessions if joined using multiple + // browsers. ralam april 23, 2020 + println("****************** User " + ejectedBy + " ejecting self " + userId) + UsersApp.ejectUserFromMeeting(outGW, liveMeeting, userId, ejectedBy, reason, EjectReasonCode.EJECT_USER) // send a system message to force disconnection - Sender.sendDisconnectClientSysMsg(meetingId, ru.id, ejectedBy, EjectReasonCode.EJECT_USER, outGW) + Sender.sendDisconnectClientSysMsg(meetingId, userId, ejectedBy, EjectReasonCode.EJECT_USER, outGW) } + } } } diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala index baec83be66..cf64e4e221 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala @@ -93,7 +93,7 @@ object UsersApp { for { user <- Users2x.ejectFromMeeting(liveMeeting.users2x, userId) - reguser <- RegisteredUsers.remove(userId, liveMeeting.registeredUsers) + reguser <- RegisteredUsers.eject(userId, liveMeeting.registeredUsers, ejectedBy) } yield { sendUserEjectedMessageToClient(outGW, meetingId, userId, ejectedBy, reason, reasonCode) sendUserLeftMeetingToAllClients(outGW, meetingId, userId) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala index 5ee7c06f52..052b4e8595 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/models/RegisteredUsers.scala @@ -81,17 +81,29 @@ object RegisteredUsers { } - def remove(id: String, users: RegisteredUsers): Option[RegisteredUser] = { - for { - ru <- findWithUserId(id, users) - } yield { + private def banUser(ejectedUser: RegisteredUser, users: RegisteredUsers, ejectedByUser: RegisteredUser): RegisteredUser = { + // Some users join with multiple browser to manage the meeting. + // Don't black list a user ejecting oneself. + // ralam april 23, 2020 + if (ejectedUser.externId != ejectedByUser.externId) { // Set a flag that user has been ejected. We flag the user instead of // removing so we can eject when user tries to rejoin with the same // external userid. // ralam april 21, 2020 - val u = ru.modify(_.ejected).setTo(true) + val u = ejectedUser.modify(_.ejected).setTo(true) users.save(u) u + } else { + users.delete(ejectedUser.id) + ejectedUser + } + } + def eject(id: String, users: RegisteredUsers, ejectedBy: String): Option[RegisteredUser] = { + for { + ru <- findWithUserId(id, users) + eu <- findWithUserId(ejectedBy, users) + } yield { + banUser(ru, users, eu) } }