Merge pull request #13764 from gustavotrott/join-param-exclude-from-dashboard

feat: Add new /join param excludeFromDashboard
This commit is contained in:
Anton Georgiev 2021-12-01 14:53:02 -05:00 committed by GitHub
commit d782beae22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 80 additions and 25 deletions

View File

@ -13,11 +13,12 @@ trait RegisterUserReqMsgHdlr {
def handleRegisterUserReqMsg(msg: RegisterUserReqMsg): Unit = {
def buildUserRegisteredRespMsg(meetingId: String, userId: String, name: String, role: String, registeredOn: Long): BbbCommonEnvCoreMsg = {
def buildUserRegisteredRespMsg(meetingId: String, userId: String, name: String,
role: String, excludeFromDashboard: Boolean, registeredOn: Long): BbbCommonEnvCoreMsg = {
val routing = collection.immutable.HashMap("sender" -> "bbb-apps-akka")
val envelope = BbbCoreEnvelope(UserRegisteredRespMsg.NAME, routing)
val header = BbbCoreHeaderWithMeetingId(UserRegisteredRespMsg.NAME, meetingId)
val body = UserRegisteredRespMsgBody(meetingId, userId, name, role, registeredOn)
val body = UserRegisteredRespMsgBody(meetingId, userId, name, role, excludeFromDashboard, registeredOn)
val event = UserRegisteredRespMsg(header, body)
BbbCommonEnvCoreMsg(envelope, event)
}
@ -26,14 +27,15 @@ trait RegisterUserReqMsgHdlr {
val regUser = RegisteredUsers.create(msg.body.intUserId, msg.body.extUserId,
msg.body.name, msg.body.role, msg.body.authToken,
msg.body.avatarURL, msg.body.guest, msg.body.authed, guestStatus, false)
msg.body.avatarURL, msg.body.guest, msg.body.authed, guestStatus, msg.body.excludeFromDashboard, false)
RegisteredUsers.add(liveMeeting.registeredUsers, regUser)
log.info("Register user success. meetingId=" + liveMeeting.props.meetingProp.intId
+ " userId=" + msg.body.extUserId + " user=" + regUser)
val event = buildUserRegisteredRespMsg(liveMeeting.props.meetingProp.intId, regUser.id, regUser.name, regUser.role, regUser.registeredOn)
val event = buildUserRegisteredRespMsg(liveMeeting.props.meetingProp.intId, regUser.id, regUser.name,
regUser.role, regUser.excludeFromDashboard, regUser.registeredOn)
outGW.send(event)
def notifyModeratorsOfGuestWaiting(guests: Vector[GuestWaiting], users: Users2x, meetingId: String): Unit = {

View File

@ -5,7 +5,7 @@ import com.softwaremill.quicklens._
object RegisteredUsers {
def create(userId: String, extId: String, name: String, roles: String,
token: String, avatar: String, guest: Boolean, authenticated: Boolean,
guestStatus: String, loggedOut: Boolean): RegisteredUser = {
guestStatus: String, excludeFromDashboard: Boolean, loggedOut: Boolean): RegisteredUser = {
new RegisteredUser(
userId,
extId,
@ -16,12 +16,13 @@ object RegisteredUsers {
guest,
authenticated,
guestStatus,
excludeFromDashboard,
System.currentTimeMillis(),
0,
false,
false,
false,
loggedOut
loggedOut,
)
}
@ -177,6 +178,7 @@ case class RegisteredUser(
guest: Boolean,
authed: Boolean,
guestStatus: String,
excludeFromDashboard: Boolean,
registeredOn: Long,
lastAuthTokenValidatedOn: Long,
joined: Boolean,

View File

@ -54,7 +54,7 @@ object FakeUserGenerator {
RandomStringGenerator.randomAlphanumericString(10) + ".png"
val ru = RegisteredUsers.create(userId = id, extId, name, role,
authToken, avatarURL, guest, authed, guestStatus = GuestStatus.ALLOW, false)
authToken, avatarURL, guest, authed, guestStatus = GuestStatus.ALLOW, false, false)
RegisteredUsers.add(users, ru)
ru
}

View File

@ -92,6 +92,7 @@ class LearningDashboardActor(
private var meetings: Map[String, Meeting] = Map()
private var meetingsLastJsonHash : Map[String,String] = Map()
private var meetingExcludedUserIds : Map[String,Vector[String]] = Map()
system.scheduler.schedule(10.seconds, 10.seconds, self, SendPeriodicReport)
@ -109,6 +110,7 @@ class LearningDashboardActor(
case m: GroupChatMessageBroadcastEvtMsg => handleGroupChatMessageBroadcastEvtMsg(m)
// User
case m: UserRegisteredRespMsg => handleUserRegisteredRespMsg(m)
case m: UserJoinedMeetingEvtMsg => handleUserJoinedMeetingEvtMsg(m)
case m: UserLeftMeetingEvtMsg => handleUserLeftMeetingEvtMsg(m)
case m: UserEmojiChangedEvtMsg => handleUserEmojiChangedEvtMsg(m)
@ -151,6 +153,18 @@ class LearningDashboardActor(
}
}
private def handleUserRegisteredRespMsg(msg: UserRegisteredRespMsg): Unit = {
for {
meeting <- meetings.values.find(m => m.intId == msg.header.meetingId)
} yield {
if(msg.body.excludeFromDashboard == true) {
meetingExcludedUserIds += (meeting.intId -> {
meetingExcludedUserIds.get(meeting.intId).getOrElse(Vector()) :+ msg.body.userId
})
}
}
}
private def handleUserJoinedMeetingEvtMsg(msg: UserJoinedMeetingEvtMsg): Unit = {
for {
meeting <- meetings.values.find(m => m.intId == msg.header.meetingId)
@ -161,7 +175,7 @@ class LearningDashboardActor(
)
})
meetings += (meeting.intId -> meeting.copy(users = meeting.users + (user.intId -> user.copy(leftOn = 0))))
this.addUserToMeeting(meeting.intId, user)
}
}
@ -241,7 +255,7 @@ class LearningDashboardActor(
)
})
meetings += (meeting.intId -> meeting.copy(users = meeting.users + (user.intId -> user.copy(leftOn = 0))))
this.addUserToMeeting(meeting.intId, user)
}
}
}
@ -404,10 +418,21 @@ class LearningDashboardActor(
sendReport(updatedMeeting)
meetings = meetings.-(updatedMeeting.intId)
meetingExcludedUserIds = meetingExcludedUserIds.-(updatedMeeting.intId)
log.info(" removed for meeting {}.",updatedMeeting.intId)
}
}
private def addUserToMeeting(meetingIntId: String, user: User): Unit = {
for {
meeting <- meetings.values.find(m => m.intId == meetingIntId)
} yield {
if(!meetingExcludedUserIds.get(meeting.intId).getOrElse(Vector()).contains(user.extId)) {
meetings += (meeting.intId -> meeting.copy(users = meeting.users + (user.intId -> user.copy(leftOn = 0))))
}
}
}
private def sendPeriodicReport(): Unit = {
meetings.map(meeting => {
sendReport(meeting._2)

View File

@ -15,14 +15,15 @@ case class RegisterUserReqMsg(
) extends BbbCoreMsg
case class RegisterUserReqMsgBody(meetingId: String, intUserId: String, name: String, role: String,
extUserId: String, authToken: String, avatarURL: String,
guest: Boolean, authed: Boolean, guestStatus: String)
guest: Boolean, authed: Boolean, guestStatus: String, excludeFromDashboard: Boolean)
object UserRegisteredRespMsg { val NAME = "UserRegisteredRespMsg" }
case class UserRegisteredRespMsg(
header: BbbCoreHeaderWithMeetingId,
body: UserRegisteredRespMsgBody
) extends BbbCoreMsg
case class UserRegisteredRespMsgBody(meetingId: String, userId: String, name: String, role: String, registeredOn: Long)
case class UserRegisteredRespMsgBody(meetingId: String, userId: String, name: String,
role: String, excludeFromDashboard: Boolean, registeredOn: Long)
object RegisteredUserJoinTimeoutMsg { val NAME = "RegisteredUserJoinTimeoutMsg" }
case class RegisteredUserJoinTimeoutMsg(

View File

@ -139,13 +139,13 @@ public class MeetingService implements MessageListener {
public void registerUser(String meetingID, String internalUserId,
String fullname, String role, String externUserID,
String authToken, String avatarURL, Boolean guest,
Boolean authed, String guestStatus) {
Boolean authed, String guestStatus, Boolean excludeFromDashboard) {
handle(new RegisterUser(meetingID, internalUserId, fullname, role,
externUserID, authToken, avatarURL, guest, authed, guestStatus));
externUserID, authToken, avatarURL, guest, authed, guestStatus, excludeFromDashboard));
Meeting m = getMeeting(meetingID);
if (m != null) {
RegisteredUser ruser = new RegisteredUser(authToken, internalUserId, guestStatus);
RegisteredUser ruser = new RegisteredUser(authToken, internalUserId, guestStatus, excludeFromDashboard);
m.userRegistered(ruser);
}
}
@ -460,7 +460,7 @@ public class MeetingService implements MessageListener {
gw.registerUser(message.meetingID,
message.internalUserId, message.fullname, message.role,
message.externUserID, message.authToken, message.avatarURL, message.guest,
message.authed, message.guestStatus);
message.authed, message.guestStatus, message.excludeFromDashboard);
}
public Meeting getMeeting(String meetingId) {

View File

@ -6,12 +6,14 @@ public class RegisteredUser {
public final Long registeredOn;
private String guestStatus;
private Boolean excludeFromDashboard;
private Long guestWaitedOn;
public RegisteredUser(String authToken, String userId, String guestStatus) {
public RegisteredUser(String authToken, String userId, String guestStatus, Boolean excludeFromDashboard) {
this.authToken = authToken;
this.userId = userId;
this.guestStatus = guestStatus;
this.excludeFromDashboard = excludeFromDashboard;
Long currentTimeMillis = System.currentTimeMillis();
this.registeredOn = currentTimeMillis;
@ -26,6 +28,14 @@ public class RegisteredUser {
return guestStatus;
}
public void setExcludeFromDashboard(Boolean excludeFromDashboard) {
this.excludeFromDashboard = excludeFromDashboard;
}
public Boolean getExcludeFromDashboard() {
return excludeFromDashboard;
}
public void updateGuestWaitedOn() {
this.guestWaitedOn = System.currentTimeMillis();
}

View File

@ -44,6 +44,7 @@ public class UserSession {
public String avatarURL;
public String guestStatus = GuestPolicy.ALLOW;
public String clientUrl = null;
public Boolean excludeFromDashboard = false;
private AtomicInteger connections = new AtomicInteger(0);

View File

@ -13,10 +13,11 @@ public class RegisterUser implements IMessage {
public final Boolean guest;
public final Boolean authed;
public final String guestStatus;
public final Boolean excludeFromDashboard;
public RegisterUser(String meetingID, String internalUserId, String fullname, String role, String externUserID,
String authToken, String avatarURL, Boolean guest,
Boolean authed, String guestStatus) {
Boolean authed, String guestStatus, Boolean excludeFromDashboard) {
this.meetingID = meetingID;
this.internalUserId = internalUserId;
this.fullname = fullname;
@ -27,5 +28,6 @@ public class RegisterUser implements IMessage {
this.guest = guest;
this.authed = authed;
this.guestStatus = guestStatus;
this.excludeFromDashboard = excludeFromDashboard;
}
}

View File

@ -18,7 +18,7 @@ public interface IPublisherService {
void endMeeting(String meetingId);
void send(String channel, String message);
void registerUser(String meetingID, String internalUserId, String fullname, String role, String externUserID,
String authToken, String avatarURL, Boolean guest, Boolean authed);
String authToken, String avatarURL, Boolean guest, Boolean excludeFromDashboard, Boolean authed);
void sendKeepAlive(String system, Long bbbWebTimestamp, Long akkaAppsTimestamp);
void sendStunTurnInfo(String meetingId, String internalUserId, Set<StunServer> stuns, Set<TurnEntry> turns);
}

View File

@ -37,7 +37,7 @@ public interface IBbbWebApiGWApp {
void registerUser(String meetingID, String internalUserId, String fullname, String role,
String externUserID, String authToken, String avatarURL,
Boolean guest, Boolean authed, String guestStatus);
Boolean guest, Boolean authed, String guestStatus, Boolean excludeFromDashboard);
void ejectDuplicateUser(String meetingID, String internalUserId, String fullname,
String externUserID);
void guestWaitingLeft(String meetingID, String internalUserId);

View File

@ -226,7 +226,7 @@ class BbbWebApiGWApp(
def registerUser(meetingId: String, intUserId: String, name: String,
role: String, extUserId: String, authToken: String, avatarURL: String,
guest: java.lang.Boolean, authed: java.lang.Boolean,
guestStatus: String): Unit = {
guestStatus: String, excludeFromDashboard: java.lang.Boolean): Unit = {
// meetingManagerActorRef ! new RegisterUser(meetingId = meetingId, intUserId = intUserId, name = name,
// role = role, extUserId = extUserId, authToken = authToken, avatarURL = avatarURL,
@ -234,7 +234,8 @@ class BbbWebApiGWApp(
val regUser = new RegisterUser(meetingId = meetingId, intUserId = intUserId, name = name,
role = role, extUserId = extUserId, authToken = authToken, avatarURL = avatarURL,
guest = guest.booleanValue(), authed = authed.booleanValue(), guestStatus = guestStatus)
guest = guest.booleanValue(), authed = authed.booleanValue(), guestStatus = guestStatus,
excludeFromDashboard = excludeFromDashboard)
val event = MsgBuilder.buildRegisterUserRequestToAkkaApps(regUser)
msgToAkkaAppsEventBus.publish(MsgToAkkaApps(toAkkaAppsChannel, event))

View File

@ -50,7 +50,8 @@ object MsgBuilder {
val header = BbbCoreHeaderWithMeetingId(RegisterUserReqMsg.NAME, msg.meetingId)
val body = RegisterUserReqMsgBody(meetingId = msg.meetingId, intUserId = msg.intUserId,
name = msg.name, role = msg.role, extUserId = msg.extUserId, authToken = msg.authToken,
avatarURL = msg.avatarURL, guest = msg.guest, authed = msg.authed, guestStatus = msg.guestStatus)
avatarURL = msg.avatarURL, guest = msg.guest, authed = msg.authed, guestStatus = msg.guestStatus,
excludeFromDashboard = msg.excludeFromDashboard)
val req = RegisterUserReqMsg(header, body)
BbbCommonEnvCoreMsg(envelope, req)
}

View File

@ -17,7 +17,7 @@ case class CreateBreakoutRoomMsg(meetingId: String, parentMeetingId: String,
case class AddUserSession(token: String, session: UserSession)
case class RegisterUser(meetingId: String, intUserId: String, name: String, role: String,
extUserId: String, authToken: String, avatarURL: String,
guest: Boolean, authed: Boolean, guestStatus: String)
guest: Boolean, authed: Boolean, guestStatus: String, excludeFromDashboard: Boolean)
case class CreateMeetingMsg(defaultProps: DefaultProps)

View File

@ -28,7 +28,8 @@ trait ToAkkaAppsSendersTrait extends SystemConfiguration {
val header = BbbCoreHeaderWithMeetingId(RegisterUserReqMsg.NAME, msg.meetingId)
val body = RegisterUserReqMsgBody(meetingId = msg.meetingId, intUserId = msg.intUserId,
name = msg.name, role = msg.role, extUserId = msg.extUserId, authToken = msg.authToken,
avatarURL = msg.avatarURL, guest = msg.guest, authed = msg.authed, guestStatus = msg.guestStatus)
avatarURL = msg.avatarURL, guest = msg.guest, authed = msg.authed, guestStatus = msg.guestStatus,
excludeFromDashboard = msg.excludeFromDashboard)
val req = RegisterUserReqMsg(header, body)
val message = BbbCommonEnvCoreMsg(envelope, req)
sendToBus(message)

View File

@ -317,6 +317,14 @@ class ApiController {
us.avatarURL = meeting.defaultAvatarURL
}
if (!StringUtils.isEmpty(params.excludeFromDashboard)) {
try {
us.excludeFromDashboard = Boolean.parseBoolean(params.excludeFromDashboard)
} catch (Exception e) {
// Do nothing, prop excludeFromDashboard was already initialized
}
}
String meetingId = meeting.getInternalId()
if (hasReachedMaxParticipants(meeting, us)) {
@ -341,7 +349,8 @@ class ApiController {
us.avatarURL,
us.guest,
us.authed,
guestStatusVal
guestStatusVal,
us.excludeFromDashboard
)
session.setMaxInactiveInterval(SESSION_TIMEOUT);