backend: refactor recording access secret retrieval to use RecordingService
This commit is contained in:
parent
3aaf976964
commit
a9360ef452
@ -5,13 +5,11 @@ import { container } from '../config/dependency-injector.config.js';
|
||||
import { INTERNAL_CONFIG } from '../config/internal-config.js';
|
||||
import { RecordingHelper } from '../helpers/recording.helper.js';
|
||||
import {
|
||||
errorRecordingNotFound,
|
||||
errorRecordingsNotFromSameRoom,
|
||||
handleError,
|
||||
internalError,
|
||||
rejectRequestFromMeetError
|
||||
} from '../models/error.model.js';
|
||||
import { RecordingRepository } from '../repositories/recording.repository.js';
|
||||
import { LoggerService } from '../services/logger.service.js';
|
||||
import { RecordingService } from '../services/recording.service.js';
|
||||
import { RequestSessionService } from '../services/request-session.service.js';
|
||||
@ -230,20 +228,14 @@ export const getRecordingMedia = async (req: Request, res: Response) => {
|
||||
|
||||
export const getRecordingUrl = async (req: Request, res: Response) => {
|
||||
const logger = container.get(LoggerService);
|
||||
const recordingService = container.get(RecordingService);
|
||||
const recordingId = req.params.recordingId;
|
||||
const privateAccess = req.query.privateAccess === 'true';
|
||||
|
||||
logger.info(`Getting URL for recording '${recordingId}'`);
|
||||
|
||||
try {
|
||||
const recordingRepository = container.get(RecordingRepository);
|
||||
const recordingSecrets = await recordingRepository.findAccessSecretsByRecordingId(recordingId);
|
||||
|
||||
if (!recordingSecrets) {
|
||||
const error = errorRecordingNotFound(recordingId);
|
||||
return rejectRequestFromMeetError(res, error);
|
||||
}
|
||||
|
||||
const recordingSecrets = await recordingService.getRecordingAccessSecrets(recordingId);
|
||||
const secret = privateAccess ? recordingSecrets.privateAccessSecret : recordingSecrets.publicAccessSecret;
|
||||
const recordingUrl = `${getBaseUrl()}/recording/${recordingId}?secret=${secret}`;
|
||||
|
||||
|
||||
@ -6,12 +6,11 @@ import {
|
||||
errorInsufficientPermissions,
|
||||
errorInvalidRecordingSecret,
|
||||
errorRecordingDisabled,
|
||||
errorRecordingNotFound,
|
||||
handleError,
|
||||
rejectRequestFromMeetError
|
||||
} from '../models/error.model.js';
|
||||
import { RecordingRepository } from '../repositories/recording.repository.js';
|
||||
import { LoggerService } from '../services/logger.service.js';
|
||||
import { RecordingService } from '../services/recording.service.js';
|
||||
import { RequestSessionService } from '../services/request-session.service.js';
|
||||
import { RoomService } from '../services/room.service.js';
|
||||
import {
|
||||
@ -141,13 +140,8 @@ export const configureRecordingAuth = async (req: Request, res: Response, next:
|
||||
try {
|
||||
const recordingId = req.params.recordingId as string;
|
||||
|
||||
const recordingRepository = container.get(RecordingRepository);
|
||||
const recordingSecrets = await recordingRepository.findAccessSecretsByRecordingId(recordingId);
|
||||
|
||||
if (!recordingSecrets) {
|
||||
const error = errorRecordingNotFound(recordingId);
|
||||
return rejectRequestFromMeetError(res, error);
|
||||
}
|
||||
const recordingService = container.get(RecordingService);
|
||||
const recordingSecrets = await recordingService.getRecordingAccessSecrets(recordingId);
|
||||
|
||||
const authValidators = [];
|
||||
|
||||
|
||||
@ -461,6 +461,25 @@ export class RecordingService {
|
||||
return UtilsHelper.filterObjectFields(recordingInfo, fields) as MeetRecordingInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the access secrets for a specific recording.
|
||||
*
|
||||
* @param recordingId - The unique identifier of the recording
|
||||
* @returns A promise that resolves to an object containing the public and private access secrets
|
||||
* @throws Will throw an error if the recording is not found
|
||||
*/
|
||||
async getRecordingAccessSecrets(
|
||||
recordingId: string
|
||||
): Promise<{ publicAccessSecret: string; privateAccessSecret: string }> {
|
||||
const recordingSecrets = await this.recordingRepository.findAccessSecretsByRecordingId(recordingId);
|
||||
|
||||
if (!recordingSecrets) {
|
||||
throw errorRecordingNotFound(recordingId);
|
||||
}
|
||||
|
||||
return recordingSecrets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a paginated list of all recordings stored in MongoDB.
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user