diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/message/senders/MsgBuilder.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/message/senders/MsgBuilder.scala index 4fcf02542d..64f76d579d 100755 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/message/senders/MsgBuilder.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/core2/message/senders/MsgBuilder.scala @@ -550,10 +550,10 @@ object MsgBuilder { BbbCommonEnvCoreMsg(envelope, event) } - def buildLearningDashboardEvtMsg(meetingId: String, activityJson: String): BbbCommonEnvCoreMsg = { + def buildLearningDashboardEvtMsg(meetingId: String, learningDashboardAccessToken: String, activityJson: String): BbbCommonEnvCoreMsg = { val routing = collection.immutable.HashMap("sender" -> "bbb-apps-akka") val envelope = BbbCoreEnvelope(LearningDashboardEvtMsg.NAME, routing) - val body = LearningDashboardEvtMsgBody(activityJson) + val body = LearningDashboardEvtMsgBody(learningDashboardAccessToken, activityJson) val header = BbbCoreHeaderWithMeetingId(LearningDashboardEvtMsg.NAME, meetingId) val event = LearningDashboardEvtMsg(header, body) diff --git a/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala b/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala index e4d621e752..5cc3cd7749 100644 --- a/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala +++ b/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/LearningDashboardActor.scala @@ -19,7 +19,6 @@ case class Meeting( intId: String, extId: String, name: String, - learningDashboardAccessToken: String, users: Map[String, User] = Map(), polls: Map[String, Poll] = Map(), screenshares: Vector[Screenshare] = Vector(), @@ -91,8 +90,9 @@ class LearningDashboardActor( ) extends Actor with ActorLogging { private var meetings: Map[String, Meeting] = Map() - private var meetingsLastJsonHash : Map[String,String] = Map() - private var meetingExcludedUserIds : Map[String,Vector[String]] = Map() + private var meetingAccessTokens: Map[String,String] = 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) @@ -373,10 +373,10 @@ class LearningDashboardActor( msg.body.props.meetingProp.intId, msg.body.props.meetingProp.extId, msg.body.props.meetingProp.name, - msg.body.props.password.learningDashboardAccessToken, ) meetings += (newMeeting.intId -> newMeeting) + meetingAccessTokens += (newMeeting.intId -> msg.body.props.password.learningDashboardAccessToken) log.info(" created for meeting {}.",msg.body.props.meetingProp.intId) } else { @@ -418,7 +418,9 @@ class LearningDashboardActor( sendReport(updatedMeeting) meetings = meetings.-(updatedMeeting.intId) + meetingAccessTokens = meetingAccessTokens.-(updatedMeeting.intId) meetingExcludedUserIds = meetingExcludedUserIds.-(updatedMeeting.intId) + meetingsLastJsonHash = meetingsLastJsonHash.-(updatedMeeting.intId) log.info(" removed for meeting {}.",updatedMeeting.intId) } } @@ -446,12 +448,16 @@ class LearningDashboardActor( val activityJsonHash : String = MessageDigest.getInstance("MD5").digest(activityJson.getBytes).mkString if(!meetingsLastJsonHash.contains(meeting.intId) || meetingsLastJsonHash.get(meeting.intId).getOrElse("") != activityJsonHash) { - val event = MsgBuilder.buildLearningDashboardEvtMsg(meeting.intId, activityJson) - outGW.send(event) + for { + learningDashboardAccessToken <- meetingAccessTokens.get(meeting.intId) + } yield { + val event = MsgBuilder.buildLearningDashboardEvtMsg(meeting.intId, learningDashboardAccessToken, activityJson) + outGW.send(event) - meetingsLastJsonHash += (meeting.intId -> activityJsonHash) + meetingsLastJsonHash += (meeting.intId -> activityJsonHash) - log.info("Activity Report sent for meeting {}",meeting.intId) + log.info("Activity Report sent for meeting {}",meeting.intId) + } } } diff --git a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/SystemMsgs.scala b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/SystemMsgs.scala index 140f846111..49f550a31d 100755 --- a/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/SystemMsgs.scala +++ b/bbb-common-message/src/main/scala/org/bigbluebutton/common2/msgs/SystemMsgs.scala @@ -232,4 +232,4 @@ case class LearningDashboardEvtMsg( header: BbbCoreHeaderWithMeetingId, body: LearningDashboardEvtMsgBody ) extends BbbCoreMsg -case class LearningDashboardEvtMsgBody(activityJson: String) +case class LearningDashboardEvtMsgBody(learningDashboardAccessToken: String, activityJson: String) diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java b/bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java index 3234239c89..9107ec9449 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/api/MeetingService.java @@ -963,10 +963,9 @@ public class MeetingService implements MessageListener { } public void processLearningDashboard(LearningDashboard message) { + //Get all data from Json instead of getMeeting(message.meetingId), to process messages received even after meeting ended JsonObject activityJsonObject = new Gson().fromJson(message.activityJson, JsonObject.class).getAsJsonObject(); - String learningDashboardAccessToken = activityJsonObject.get("learningDashboardAccessToken").getAsString(); - Map logData = new HashMap(); logData.put("meetingId", activityJsonObject.get("intId").getAsString()); logData.put("externalMeetingId", activityJsonObject.get("extId").getAsString()); @@ -979,7 +978,7 @@ public class MeetingService implements MessageListener { log.info(" --analytics-- data={}", logStr); - learningDashboardService.writeJsonDataFile(message.meetingId, learningDashboardAccessToken, message.activityJson); + learningDashboardService.writeJsonDataFile(message.meetingId, message.learningDashboardAccessToken, message.activityJson); } @Override diff --git a/bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/LearningDashboard.java b/bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/LearningDashboard.java index ec6fdfc2f8..a8e917b2b3 100755 --- a/bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/LearningDashboard.java +++ b/bbb-common-web/src/main/java/org/bigbluebutton/api/messaging/messages/LearningDashboard.java @@ -3,9 +3,11 @@ package org.bigbluebutton.api.messaging.messages; public class LearningDashboard implements IMessage { public final String meetingId; public final String activityJson; + public final String learningDashboardAccessToken; - public LearningDashboard(String meetingId, String activityJson) { + public LearningDashboard(String meetingId, String learningDashboardAccessToken, String activityJson) { this.meetingId = meetingId; this.activityJson = activityJson; + this.learningDashboardAccessToken = learningDashboardAccessToken; } } diff --git a/bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/OldMeetingMsgHdlrActor.scala b/bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/OldMeetingMsgHdlrActor.scala index 4e9c98fc27..a06888ad5d 100755 --- a/bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/OldMeetingMsgHdlrActor.scala +++ b/bbb-common-web/src/main/scala/org/bigbluebutton/api2/meeting/OldMeetingMsgHdlrActor.scala @@ -182,7 +182,7 @@ class OldMeetingMsgHdlrActor(val olgMsgGW: OldMessageReceivedGW) } def handleLearningDashboardEvtMsg(msg: LearningDashboardEvtMsg): Unit = { - olgMsgGW.handle(new LearningDashboard(msg.header.meetingId, msg.body.activityJson)) + olgMsgGW.handle(new LearningDashboard(msg.header.meetingId, msg.body.learningDashboardAccessToken, msg.body.activityJson)) } } diff --git a/bbb-learning-dashboard/src/App.js b/bbb-learning-dashboard/src/App.js index c387b231fc..198bd7b11b 100644 --- a/bbb-learning-dashboard/src/App.js +++ b/bbb-learning-dashboard/src/App.js @@ -48,18 +48,18 @@ class App extends React.Component { if (typeof params.report !== 'undefined') { learningDashboardAccessToken = params.report; } else { - const cookieName = `learningDashboardAccessToken-${params.meeting}`; + const cookieName = `ld-${params.meeting}`; const cDecoded = decodeURIComponent(document.cookie); const cArr = cDecoded.split('; '); cArr.forEach((val) => { if (val.indexOf(`${cookieName}=`) === 0) learningDashboardAccessToken = val.substring((`${cookieName}=`).length); }); - // Extend AccessToken lifetime by 30d (in each access) + // Extend AccessToken lifetime by 7d (in each access) if (learningDashboardAccessToken !== '') { const cookieExpiresDate = new Date(); - cookieExpiresDate.setTime(cookieExpiresDate.getTime() + (3600000 * 24 * 30)); - document.cookie = `learningDashboardAccessToken-${meetingId}=${learningDashboardAccessToken}; expires=${cookieExpiresDate.toGMTString()}; path=/;SameSite=None;Secure`; + cookieExpiresDate.setTime(cookieExpiresDate.getTime() + (3600000 * 24 * 7)); + document.cookie = `ld-${meetingId}=${learningDashboardAccessToken}; expires=${cookieExpiresDate.toGMTString()}; path=/;SameSite=None;Secure`; } } diff --git a/bigbluebutton-html5/imports/ui/components/learning-dashboard/service.js b/bigbluebutton-html5/imports/ui/components/learning-dashboard/service.js index 9f939a3697..6402d777a2 100644 --- a/bigbluebutton-html5/imports/ui/components/learning-dashboard/service.js +++ b/bigbluebutton-html5/imports/ui/components/learning-dashboard/service.js @@ -39,9 +39,9 @@ const getLearningDashboardAccessToken = () => (( const setLearningDashboardCookie = () => { const learningDashboardAccessToken = getLearningDashboardAccessToken(); if (learningDashboardAccessToken !== null) { - const cookieExpiresDate = new Date(); - cookieExpiresDate.setTime(cookieExpiresDate.getTime() + (3600000 * 24 * 30)); // keep cookie 30d - document.cookie = `learningDashboardAccessToken-${Auth.meetingID}=${getLearningDashboardAccessToken()}; expires=${cookieExpiresDate.toGMTString()}; path=/`; + const lifetime = new Date(); + lifetime.setTime(lifetime.getTime() + (3600000)); // 1h (extends 7d when open Dashboard) + document.cookie = `ld-${Auth.meetingID}=${getLearningDashboardAccessToken()}; expires=${lifetime.toGMTString()}; path=/`; return true; } return false;