Saving role and waitingForAcceptance status when user left so can be updated if user reconnect

This commit is contained in:
Pedro Beschorner Marin 2015-07-03 14:44:49 +00:00
parent 324ed1b9ab
commit 6582cb6dd3
2 changed files with 18 additions and 4 deletions

View File

@ -56,7 +56,8 @@ case class RegisteredUser (
name: String, name: String,
role: Role.Role, role: Role.Role,
authToken: String, authToken: String,
guest: Boolean guest: Boolean,
waitingForAcceptance: Boolean
) )
case class Voice( case class Voice(

View File

@ -108,7 +108,7 @@ trait UsersApp {
logger.info("Register user failed: reason=[meeting has ended] mid=[" + meetingID + "] uid=[" + msg.userID + "]") logger.info("Register user failed: reason=[meeting has ended] mid=[" + meetingID + "] uid=[" + msg.userID + "]")
sendMeetingHasEnded(msg.userID) sendMeetingHasEnded(msg.userID)
} else { } else {
val regUser = new RegisteredUser(msg.userID, msg.extUserID, msg.name, msg.role, msg.authToken, msg.guest) val regUser = new RegisteredUser(msg.userID, msg.extUserID, msg.name, msg.role, msg.authToken, msg.guest, msg.guest)
regUsers += msg.authToken -> regUser regUsers += msg.authToken -> regUser
logger.info("Register user success: mid=[" + meetingID + "] uid=[" + msg.userID + "]") logger.info("Register user success: mid=[" + meetingID + "] uid=[" + msg.userID + "]")
outGW.send(new UserRegistered(meetingID, recorded, regUser)) outGW.send(new UserRegistered(meetingID, recorded, regUser))
@ -290,7 +290,7 @@ trait UsersApp {
false, false, false, false) false, false, false, false)
} }
} }
val waitingForAcceptance = ru.guest && guestPolicy == GuestPolicy.ASK_MODERATOR; val waitingForAcceptance = ru.guest && guestPolicy == GuestPolicy.ASK_MODERATOR && ru.waitingForAcceptance
val uvo = new UserVO(msg.userID, ru.externId, ru.name, val uvo = new UserVO(msg.userID, ru.externId, ru.name,
ru.role, ru.guest, waitingForAcceptance=waitingForAcceptance, mood="", presenter=false, ru.role, ru.guest, waitingForAcceptance=waitingForAcceptance, mood="", presenter=false,
hasStream=false, locked=getInitialLockStatus(ru.role), hasStream=false, locked=getInitialLockStatus(ru.role),
@ -326,6 +326,7 @@ trait UsersApp {
user foreach { u => user foreach { u =>
logger.info("User left meeting: mid=[" + meetingID + "] uid=[" + u.userID + "]") logger.info("User left meeting: mid=[" + meetingID + "] uid=[" + u.userID + "]")
outGW.send(new UserLeft(msg.meetingID, recorded, u)) outGW.send(new UserLeft(msg.meetingID, recorded, u))
updateRegUser(u)
if (u.presenter) { if (u.presenter) {
/* The current presenter has left the meeting. Find a moderator and make /* The current presenter has left the meeting. Find a moderator and make
@ -504,10 +505,22 @@ trait UsersApp {
} }
} }
} }
def getRegisteredUser(userID: String): Option[RegisteredUser] = { def getRegisteredUser(userID: String): Option[RegisteredUser] = {
regUsers.values find (ru => userID contains ru.id) regUsers.values find (ru => userID contains ru.id)
} }
def updateRegUser(uvo: UserVO) {
getRegisteredUser(uvo.userID) match {
case Some(ru) => {
val regUser = new RegisteredUser(uvo.userID, uvo.externUserID, uvo.name, uvo.role, ru.authToken, uvo.guest, uvo.waitingForAcceptance)
regUsers -= ru.authToken
regUsers += ru.authToken -> regUser
}
case None =>
}
}
def removeRegUser(userID: String) { def removeRegUser(userID: String) {
getRegisteredUser(userID) match { getRegisteredUser(userID) match {
case Some(ru) => regUsers -= ru.authToken case Some(ru) => regUsers -= ru.authToken