- end meeting after 2 minutes (configrable) after the last authenticated user leaves

This commit is contained in:
Richard Alam 2018-07-03 13:48:57 -07:00
parent 381e72beed
commit fb234ae882
9 changed files with 68 additions and 2 deletions

View File

@ -82,6 +82,8 @@ services {
apps {
checkPermissions = true
endMeetingWhenNoMoreAuthedUsers = false
endMeetingWhenNoMoreAuthedUsersAfterMinutes = 2
}
voiceConf {

View File

@ -63,4 +63,7 @@ trait SystemConfiguration {
lazy val voiceConfRecordPath = Try(config.getString("voiceConf.recordPath")).getOrElse("/var/freeswitch/meetings")
lazy val recordingChapterBreakLenghtInMinutes = Try(config.getInt("recording.chapterBreakLengthInMinutes")).getOrElse(180)
lazy val endMeetingWhenNoMoreAuthedUsers = Try(config.getBoolean("apps.endMeetingWhenNoMoreAuthedUsers")).getOrElse(false)
lazy val endMeetingWhenNoMoreAuthedUsersAfterMinutes = Try(config.getInt("apps.endMeetingWhenNoMoreAuthedUsersAfterMinutes")).getOrElse(2)
}

View File

@ -1,5 +1,6 @@
package org.bigbluebutton.core.apps.users
import org.bigbluebutton.common2.domain.MeetingStatus
import org.bigbluebutton.common2.msgs.UserLeaveReqMsg
import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.apps.presentationpod.PresentationPodsApp
@ -7,6 +8,7 @@ import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.models.Users2x
import org.bigbluebutton.core.running.{ MeetingActor, OutMsgRouter }
import org.bigbluebutton.core.util.TimeUtil
import org.bigbluebutton.core2.MeetingStatus2x
import org.bigbluebutton.core2.message.senders.MsgBuilder
trait UserLeaveReqMsgHdlr {
@ -36,6 +38,11 @@ trait UserLeaveReqMsgHdlr {
} yield {
log.info("User left meeting. meetingId=" + props.meetingProp.intId + " userId=" + u.intId + " user=" + u)
val authedUsers = Users2x.findAllAuthedUsers(liveMeeting.users2x)
if (u.authed && authedUsers.isEmpty) {
MeetingStatus2x.setLastAuthedUserLeftOn(liveMeeting.status)
}
captionApp2x.handleUserLeavingMsg(msg.body.userId, liveMeeting, msgBus)
stopRecordingIfAutoStart2x(outGW, liveMeeting, state)

View File

@ -33,4 +33,5 @@ object MeetingEndReason {
val ENDED_AFTER_USER_LOGGED_OUT = "ENDED_AFTER_USER_LOGGED_OUT"
val ENDED_AFTER_EXCEEDING_DURATION = "ENDED_AFTER_EXCEEDING_DURATION"
val ENDED_BY_PARENT = "ENDED_BY_PARENT"
val ENDED_DUE_TO_NO_AUTHED_USER = "ENDED_DUE_TO_NO_AUTHED_USER"
}

View File

@ -110,6 +110,10 @@ object Users2x {
users.toVector.find(u => u.role == Roles.MODERATOR_ROLE)
}
def findAllAuthedUsers(users: Users2x): Vector[UserState] = {
users.toVector.find(u => u.authed).toVector
}
def addUserToPresenterGroup(users: Users2x, userIdToAdd: String): Boolean = {
users.updatePresenterGroup(users.presenterGroup.filterNot(_ == userIdToAdd).:+(userIdToAdd)) // ensure no repetition
users.presenterGroup.contains(userIdToAdd)

View File

@ -58,6 +58,16 @@ trait HandlerHelpers extends SystemConfiguration {
UsersApp.automaticallyAssignPresenter(outGW, liveMeeting)
}
if (newUser.authed) {
if (!MeetingStatus2x.hasAuthedUserJoined(liveMeeting.status)) {
MeetingStatus2x.authUserHadJoined(liveMeeting.status)
}
if (MeetingStatus2x.getLastAuthedUserLeftOn(liveMeeting.status) > 0) {
MeetingStatus2x.resetLastAuthedUserLeftOn(liveMeeting.status)
}
}
newState.update(newState.expiryTracker.setUserHasJoined())
case None =>
state

View File

@ -9,7 +9,7 @@ import org.bigbluebutton.core.apps.groupchats.{ GroupChatApp, GroupChatHdlrs }
import org.bigbluebutton.core.apps.presentationpod._
import org.bigbluebutton.core.apps.users._
import org.bigbluebutton.core.apps.whiteboard.ClientToServerLatencyTracerMsgHdlr
import org.bigbluebutton.core.domain.{ MeetingExpiryTracker, MeetingInactivityTracker, MeetingRecordingTracker, MeetingState2x }
import org.bigbluebutton.core.domain._
import org.bigbluebutton.core.util.TimeUtil
import org.bigbluebutton.common2.domain.DefaultProps
import org.bigbluebutton.core.api._
@ -434,6 +434,8 @@ class MeetingActor(
setRecordingChapterBreak()
processUserInactivityAudit()
checkIfNeetToEndMeetingWhenNoAuthedUsers(liveMeeting)
}
var lastRecBreakSentOn = expiryTracker.startedOnInMs
@ -477,6 +479,26 @@ class MeetingActor(
}
private def checkIfNeetToEndMeetingWhenNoAuthedUsers(liveMeeting: LiveMeeting): Unit = {
val authUserJoined = MeetingStatus2x.hasAuthedUserJoined(liveMeeting.status)
if (endMeetingWhenNoMoreAuthedUsers &&
!liveMeeting.props.meetingProp.isBreakout &&
authUserJoined) {
val lastAuthedUserLeftLimitMs = TimeUtil.timeNowInMs() - MeetingStatus2x.getLastAuthedUserLeftOn(liveMeeting.status)
if (lastAuthedUserLeftLimitMs > TimeUtil.minutesToMillis(endMeetingWhenNoMoreAuthedUsersAfterMinutes)) {
val authedUsers = Users2x.findAllAuthedUsers(liveMeeting.users2x)
if (authedUsers.isEmpty) {
sendEndMeetingDueToExpiry(
MeetingEndReason.ENDED_DUE_TO_NO_AUTHED_USER,
eventBus, outGW, liveMeeting
)
}
}
}
}
def handleExtendMeetingDuration(msg: ExtendMeetingDuration) {
}

View File

@ -2,6 +2,8 @@ package org.bigbluebutton.core2
import java.util.concurrent.TimeUnit
import org.bigbluebutton.core.util.TimeUtil
case class Permissions(
disableCam: Boolean = false,
disableMic: Boolean = false,
@ -45,6 +47,13 @@ object MeetingStatus2x {
def recordingStopped(status: MeetingStatus2x) = status.recording = false
def isRecording(status: MeetingStatus2x): Boolean = status.recording
def authUserHadJoined(status: MeetingStatus2x) = status.authedUserHasJoined = true
def hasAuthedUserJoined(status: MeetingStatus2x): Boolean = status.authedUserHasJoined
def setLastAuthedUserLeftOn(status: MeetingStatus2x) = status.lastAuthedUserLeftOn = TimeUtil.timeNowInMs()
def getLastAuthedUserLeftOn(status: MeetingStatus2x): Long = status.lastAuthedUserLeftOn
def resetLastAuthedUserLeftOn(status: MeetingStatus2x) = status.lastAuthedUserLeftOn = 0L
def voiceRecordingStart(status2x: MeetingStatus2x, stream: String): VoiceRecordingStream = {
val vrs = new VoiceRecordingStream(stream, recording = false, createdOn = System.currentTimeMillis, ackedOn = None, stoppedOn = None)
status2x.voiceRecordings += vrs.stream -> vrs
@ -115,6 +124,8 @@ class MeetingStatus2x {
private var webcamsOnlyForModerator = false
private var authedUserHasJoined = false
private var lastAuthedUserLeftOn = 0L
}
case class VoiceRecordingStream(stream: String, recording: Boolean, createdOn: Long, ackedOn: Option[Long], stoppedOn: Option[Long])

View File

@ -249,12 +249,18 @@ class ApiController {
errors.missingParamError("checksum");
}
Boolean authenticated = false;
Boolean guest = false;
if (!StringUtils.isEmpty(params.guest)) {
guest = Boolean.parseBoolean(params.guest)
} else {
// guest param has not been passed. Make user as
// authenticated by default. (ralam july 3, 2018)
authenticated = true
}
Boolean authenticated = false;
if (!StringUtils.isEmpty(params.auth)) {
authenticated = Boolean.parseBoolean(params.auth)
}