Merge pull request #4153 from ritzalam/log-meeting-expiry-reasone
- reset last user left timestamp when user joins meeting
This commit is contained in:
commit
7da4d1cba9
@ -1,95 +1,95 @@
|
|||||||
package org.bigbluebutton.core.domain
|
package org.bigbluebutton.core.domain
|
||||||
|
|
||||||
import org.bigbluebutton.core.util.TimeUtil
|
import org.bigbluebutton.core.util.TimeUtil
|
||||||
|
|
||||||
case class MeetingInactivityTracker(
|
case class MeetingInactivityTracker(
|
||||||
val maxInactivityTimeoutInMs: Long,
|
val maxInactivityTimeoutInMs: Long,
|
||||||
val warningBeforeMaxInMs: Long,
|
val warningBeforeMaxInMs: Long,
|
||||||
lastActivityTimestampInMs: Long,
|
lastActivityTimestampInMs: Long,
|
||||||
warningSent: Boolean,
|
warningSent: Boolean,
|
||||||
warningSentOnTimestampInMs: Long
|
warningSentOnTimestampInMs: Long
|
||||||
) {
|
) {
|
||||||
def setWarningSentAndTimestamp(nowInMs: Long): MeetingInactivityTracker = {
|
def setWarningSentAndTimestamp(nowInMs: Long): MeetingInactivityTracker = {
|
||||||
copy(warningSent = true, warningSentOnTimestampInMs = nowInMs)
|
copy(warningSent = true, warningSentOnTimestampInMs = nowInMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
def resetWarningSentAndTimestamp(): MeetingInactivityTracker = {
|
def resetWarningSentAndTimestamp(): MeetingInactivityTracker = {
|
||||||
copy(warningSent = false, warningSentOnTimestampInMs = 0L)
|
copy(warningSent = false, warningSentOnTimestampInMs = 0L)
|
||||||
}
|
}
|
||||||
|
|
||||||
def updateLastActivityTimestamp(nowInMs: Long): MeetingInactivityTracker = {
|
def updateLastActivityTimestamp(nowInMs: Long): MeetingInactivityTracker = {
|
||||||
copy(lastActivityTimestampInMs = nowInMs)
|
copy(lastActivityTimestampInMs = nowInMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
def hasRecentActivity(nowInMs: Long): Boolean = {
|
def hasRecentActivity(nowInMs: Long): Boolean = {
|
||||||
nowInMs - lastActivityTimestampInMs < maxInactivityTimeoutInMs - warningBeforeMaxInMs
|
nowInMs - lastActivityTimestampInMs < maxInactivityTimeoutInMs - warningBeforeMaxInMs
|
||||||
}
|
}
|
||||||
|
|
||||||
def isMeetingInactive(nowInMs: Long): Boolean = {
|
def isMeetingInactive(nowInMs: Long): Boolean = {
|
||||||
warningSent && (nowInMs - lastActivityTimestampInMs) > maxInactivityTimeoutInMs
|
warningSent && (nowInMs - lastActivityTimestampInMs) > maxInactivityTimeoutInMs
|
||||||
}
|
}
|
||||||
|
|
||||||
def timeLeftInMs(nowInMs: Long): Long = {
|
def timeLeftInMs(nowInMs: Long): Long = {
|
||||||
lastActivityTimestampInMs + maxInactivityTimeoutInMs - nowInMs
|
lastActivityTimestampInMs + maxInactivityTimeoutInMs - nowInMs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case class MeetingExpiryTracker(
|
case class MeetingExpiryTracker(
|
||||||
startedOnInMs: Long,
|
startedOnInMs: Long,
|
||||||
userHasJoined: Boolean,
|
userHasJoined: Boolean,
|
||||||
lastUserLeftOnInMs: Option[Long],
|
lastUserLeftOnInMs: Option[Long],
|
||||||
durationInMs: Long,
|
durationInMs: Long,
|
||||||
meetingExpireIfNoUserJoinedInMs: Long,
|
meetingExpireIfNoUserJoinedInMs: Long,
|
||||||
meetingExpireWhenLastUserLeftInMs: Long
|
meetingExpireWhenLastUserLeftInMs: Long
|
||||||
) {
|
) {
|
||||||
def setUserHasJoined(): MeetingExpiryTracker = {
|
def setUserHasJoined(): MeetingExpiryTracker = {
|
||||||
if (!userHasJoined) {
|
if (!userHasJoined) {
|
||||||
copy(userHasJoined = true)
|
copy(userHasJoined = true, lastUserLeftOnInMs = None)
|
||||||
} else {
|
} else {
|
||||||
copy()
|
this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def setLastUserLeftOn(timestampInMs: Long): MeetingExpiryTracker = {
|
def setLastUserLeftOn(timestampInMs: Long): MeetingExpiryTracker = {
|
||||||
copy(lastUserLeftOnInMs = Some(timestampInMs))
|
copy(lastUserLeftOnInMs = Some(timestampInMs))
|
||||||
}
|
}
|
||||||
|
|
||||||
def hasMeetingExpiredAfterLastUserLeft(timestampInMs: Long): Boolean = {
|
def hasMeetingExpiredAfterLastUserLeft(timestampInMs: Long): Boolean = {
|
||||||
val expire = for {
|
val expire = for {
|
||||||
lastUserLeftOn <- lastUserLeftOnInMs
|
lastUserLeftOn <- lastUserLeftOnInMs
|
||||||
} yield {
|
} yield {
|
||||||
timestampInMs - lastUserLeftOn > meetingExpireWhenLastUserLeftInMs
|
timestampInMs - lastUserLeftOn > meetingExpireWhenLastUserLeftInMs
|
||||||
}
|
}
|
||||||
|
|
||||||
expire.getOrElse(false)
|
expire.getOrElse(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
def hasMeetingExpired(timestampInMs: Long): (Boolean, Option[String]) = {
|
def hasMeetingExpired(timestampInMs: Long): (Boolean, Option[String]) = {
|
||||||
if (hasMeetingExpiredNeverBeenJoined(timestampInMs)) {
|
if (hasMeetingExpiredNeverBeenJoined(timestampInMs)) {
|
||||||
(true, Some(MeetingEndReason.ENDED_WHEN_NOT_JOINED))
|
(true, Some(MeetingEndReason.ENDED_WHEN_NOT_JOINED))
|
||||||
} else if (meetingOverDuration(timestampInMs)) {
|
} else if (meetingOverDuration(timestampInMs)) {
|
||||||
(true, Some(MeetingEndReason.ENDED_AFTER_EXCEEDING_DURATION))
|
(true, Some(MeetingEndReason.ENDED_AFTER_EXCEEDING_DURATION))
|
||||||
} else if (hasMeetingExpiredAfterLastUserLeft(timestampInMs)) {
|
} else if (hasMeetingExpiredAfterLastUserLeft(timestampInMs)) {
|
||||||
(true, Some(MeetingEndReason.ENDED_WHEN_LAST_USER_LEFT))
|
(true, Some(MeetingEndReason.ENDED_WHEN_LAST_USER_LEFT))
|
||||||
} else {
|
} else {
|
||||||
(false, None)
|
(false, None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def hasMeetingExpiredNeverBeenJoined(nowInMs: Long): Boolean = {
|
def hasMeetingExpiredNeverBeenJoined(nowInMs: Long): Boolean = {
|
||||||
!userHasJoined && (nowInMs - startedOnInMs > meetingExpireIfNoUserJoinedInMs)
|
!userHasJoined && (nowInMs - startedOnInMs > meetingExpireIfNoUserJoinedInMs)
|
||||||
}
|
}
|
||||||
|
|
||||||
def meetingOverDuration(nowInMs: Long): Boolean = {
|
def meetingOverDuration(nowInMs: Long): Boolean = {
|
||||||
if (durationInMs == 0) {
|
if (durationInMs == 0) {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
nowInMs > startedOnInMs + durationInMs
|
nowInMs > startedOnInMs + durationInMs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def endMeetingTime(): Long = {
|
def endMeetingTime(): Long = {
|
||||||
startedOnInMs + durationInMs
|
startedOnInMs + durationInMs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@ package org.bigbluebutton.core.running
|
|||||||
|
|
||||||
import org.bigbluebutton.SystemConfiguration
|
import org.bigbluebutton.SystemConfiguration
|
||||||
import org.bigbluebutton.common2.msgs._
|
import org.bigbluebutton.common2.msgs._
|
||||||
import org.bigbluebutton.core.api.{ BreakoutRoomEndedInternalMsg, DestroyMeetingInternalMsg, RecordingStatusChanged }
|
import org.bigbluebutton.core.api.{ BreakoutRoomEndedInternalMsg, DestroyMeetingInternalMsg }
|
||||||
import org.bigbluebutton.core.bus.{ BigBlueButtonEvent, InternalEventBus }
|
import org.bigbluebutton.core.bus.{ BigBlueButtonEvent, InternalEventBus }
|
||||||
import org.bigbluebutton.core.domain.{ MeetingExpiryTracker, MeetingState2x }
|
import org.bigbluebutton.core.domain.{ MeetingState2x }
|
||||||
import org.bigbluebutton.core.models._
|
import org.bigbluebutton.core.models._
|
||||||
import org.bigbluebutton.core2.MeetingStatus2x
|
import org.bigbluebutton.core2.MeetingStatus2x
|
||||||
import org.bigbluebutton.core2.message.senders.{ MsgBuilder, UserJoinedMeetingEvtMsgBuilder }
|
import org.bigbluebutton.core2.message.senders.{ MsgBuilder, UserJoinedMeetingEvtMsgBuilder }
|
||||||
|
Loading…
Reference in New Issue
Block a user