Skip to content

Commit

Permalink
Fixed bugs with recording filtered and session creator checks
Browse files Browse the repository at this point in the history
  • Loading branch information
CSantosM committed May 3, 2023
1 parent 7858586 commit d4a8968
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public ResponseEntity<Map<String, Object>> createConnection(
boolean hasParticipantValidToken = this.openviduService.isParticipantSessionValid(sessionId,
participantCookie);
boolean hasValidToken = hasModeratorValidToken || hasParticipantValidToken;
boolean isSessionCreator = hasValidToken || sessionCreated.getActiveConnections().size() == 0;
boolean iAmTheFirstConnection = sessionCreated.getActiveConnections().size() == 0;
boolean isSessionCreator = hasModeratorValidToken || iAmTheFirstConnection;

OpenViduRole role = isSessionCreator ? OpenViduRole.MODERATOR : OpenViduRole.PUBLISHER;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public List<Recording> listRecordingsBySessionIdAndDate(String sessionId, long d
List<Recording> recordings = this.listAllRecordings();
List<Recording> recordingsAux = new ArrayList<Recording>();
for (Recording recording : recordings) {
if (recording.getSessionId().equals(sessionId) && date <= recording.getCreatedAt()) {
if (recording.getSessionId().equals(sessionId) && recording.getCreatedAt() + recording.getDuration() * 1000 >= date) {
recordingsAux.add(recording);
}
}
Expand Down
3 changes: 2 additions & 1 deletion openvidu-call-back/src/controllers/SessionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ app.post('/', async (req: Request, res: Response) => {
const hasModeratorValidToken = openviduService.isModeratorSessionValid(sessionId, req.cookies);
const hasParticipantValidToken = openviduService.isParticipantSessionValid(sessionId, req.cookies);
const hasValidToken = hasModeratorValidToken || hasParticipantValidToken;
const isSessionCreator = hasValidToken || sessionCreated.activeConnections.length === 0;
const iAmFirstConnection = sessionCreated.activeConnections.length === 0;
const isSessionCreator = hasModeratorValidToken || iAmFirstConnection;
const role: OpenViduRole = isSessionCreator ? OpenViduRole.MODERATOR : OpenViduRole.PUBLISHER;

const response = {
Expand Down
5 changes: 4 additions & 1 deletion openvidu-call-back/src/services/OpenViduService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ export class OpenViduService {

public async listRecordingsBySessionIdAndDate(sessionId: string, date: number) {
const recordingList: Recording[] = await this.listAllRecordings();
return recordingList.filter((recording) => recording.sessionId === sessionId && date <= recording.createdAt);
return recordingList.filter((recording) => {
const recordingDateEnd = recording.createdAt + recording.duration * 1000;
return recording.sessionId === sessionId && recordingDateEnd >= date;
});
}

public async startBroadcasting(sessionId: string, url: string): Promise<void> {
Expand Down

0 comments on commit d4a8968

Please sign in to comment.