backend: Refactor webhook service to streamline recording started logic and rename saveRoomSecrets method

This commit is contained in:
Carlos Santos 2025-04-10 12:26:30 +02:00
parent dbce119f5a
commit 4c5f53261c

View File

@ -198,10 +198,7 @@ export class LivekitWebhookService {
// Send webhook notification // Send webhook notification
switch (webhookAction) { switch (webhookAction) {
case 'started': case 'started':
tasks.push( tasks.push(this.openViduWebhookService.sendRecordingStartedWebhook(recordingInfo));
this.saveRoomSecretsIfNeeded(roomId),
this.openViduWebhookService.sendRecordingStartedWebhook(recordingInfo)
);
break; break;
case 'updated': case 'updated':
tasks.push(this.openViduWebhookService.sendRecordingUpdatedWebhook(recordingInfo)); tasks.push(this.openViduWebhookService.sendRecordingUpdatedWebhook(recordingInfo));
@ -219,6 +216,7 @@ export class LivekitWebhookService {
break; break;
case 'ended': case 'ended':
tasks.push( tasks.push(
this.saveRoomSecretsFileIfNeeded(roomId),
this.openViduWebhookService.sendRecordingEndedWebhook(recordingInfo), this.openViduWebhookService.sendRecordingEndedWebhook(recordingInfo),
this.recordingService.releaseRoomRecordingActiveLock(roomId) this.recordingService.releaseRoomRecordingActiveLock(roomId)
); );
@ -243,7 +241,7 @@ export class LivekitWebhookService {
* and moderator secrets, and saves them to an S3 bucket under the path * and moderator secrets, and saves them to an S3 bucket under the path
* `${MEET_S3_RECORDINGS_PREFIX}/.metadata/${roomId}/secrets.json`. * `${MEET_S3_RECORDINGS_PREFIX}/.metadata/${roomId}/secrets.json`.
*/ */
protected async saveRoomSecretsIfNeeded(roomId: string): Promise<void> { protected async saveRoomSecretsFileIfNeeded(roomId: string): Promise<void> {
try { try {
const filePath = `${MEET_S3_RECORDINGS_PREFIX}/.metadata/${roomId}/secrets.json`; const filePath = `${MEET_S3_RECORDINGS_PREFIX}/.metadata/${roomId}/secrets.json`;
const fileExists = await this.s3Service.exists(filePath); const fileExists = await this.s3Service.exists(filePath);