Include infos about meeting endedOn and fix problem where user leftOn was never set if meeting ends before they left

This commit is contained in:
Gustavo Trott 2021-08-02 11:16:08 -03:00
parent 369cd25165
commit 42e32b7ba8
2 changed files with 45 additions and 22 deletions

View File

@ -17,9 +17,12 @@ case class MeetingActivityTracker(
intId: String,
extId: String,
name: String,
activityReportAccessToken: String,
users: Map[String, UserActivityTracker] = Map(),
polls: Map[String, Poll] = Map(),
screenshares: Vector[Screenshare] = Vector(),
createdOn: Long = System.currentTimeMillis(),
endedOn: Long = 0,
)
case class UserActivityTracker(
@ -318,6 +321,7 @@ class ActivityTrackerActor(
msg.body.props.meetingProp.intId,
msg.body.props.meetingProp.extId,
msg.body.props.meetingProp.name,
msg.body.props.password.activityReportAccessToken,
)
meetings += (newMeeting.intId -> newMeeting)
@ -332,22 +336,38 @@ class ActivityTrackerActor(
for {
meeting <- meetings.values.find(m => m.intId == msg.body.meetingId)
} yield {
//Send report one last time
sendPeriodicReport()
meetings = meetings.-(meeting.intId)
log.info("ActivityTracker removed for meeting {}.",meeting.intId)
//Update endedOn
val endedOn : Long = System.currentTimeMillis()
var updatedMeeting = meeting.copy(endedOn = endedOn)
//Set all users leftOn
updatedMeeting.users.values.filter(u => u.leftOn == 0).map(user => {
updatedMeeting = updatedMeeting.copy(users = updatedMeeting.users + (user.intId -> user.copy(leftOn = endedOn)))
})
meetings += (updatedMeeting.intId -> updatedMeeting)
//Send report one last time
sendReport(updatedMeeting)
meetings = meetings.-(updatedMeeting.intId)
log.info("ActivityTracker removed for meeting {}.",updatedMeeting.intId)
}
}
private def sendPeriodicReport(): Unit = {
meetings.map(meeting => {
val activityJson: String = JsonUtil.toJson(meeting._2)
val event = MsgBuilder.buildActivityReportEvtMsg(meeting._2.intId, activityJson)
outGW.send(event)
log.info("Activity Report sent for meeting {}",meeting._2.intId)
sendReport(meeting._2)
})
}
private def sendReport(meeting : MeetingActivityTracker): Unit = {
val activityJson: String = JsonUtil.toJson(meeting)
val event = MsgBuilder.buildActivityReportEvtMsg(meeting.intId, activityJson)
outGW.send(event)
log.info("Activity Report sent for meeting {}",meeting.intId)
}
}

View File

@ -40,6 +40,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.utils.URIBuilder;
import org.bigbluebutton.api.HTML5LoadBalancingService;
@ -953,21 +954,23 @@ public class MeetingService implements MessageListener {
}
public void processActivityReport(ActivityReport message) {
Meeting m = getMeeting(message.meetingId);
if (m != null) {
Map<String, Object> logData = new HashMap<String, Object>();
logData.put("meetingId", m.getInternalId());
logData.put("externalMeetingId", m.getExternalId());
logData.put("name", m.getName());
logData.put("logCode", "update_activity_json");
logData.put("description", "Updating activities json.");
//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 activityReportAccessToken = activityJsonObject.get("activityReportAccessToken").getAsString();
Gson gson = new Gson();
String logStr = gson.toJson(logData);
Map<String, Object> logData = new HashMap<String, Object>();
logData.put("meetingId", activityJsonObject.get("intId").getAsString());
logData.put("externalMeetingId", activityJsonObject.get("extId").getAsString());
logData.put("name", activityJsonObject.get("name").getAsString());
logData.put("logCode", "update_activity_json");
logData.put("description", "Updating activities json.");
log.info(" --analytics-- data={}", logStr);
activityService.writeActivityJsonFile(message.meetingId, m.getActivityReportAccessToken(), message.activityJson);
}
Gson gson = new Gson();
String logStr = gson.toJson(logData);
log.info(" --analytics-- data={}", logStr);
activityService.writeActivityJsonFile(message.meetingId, activityReportAccessToken, message.activityJson);
}
@Override