-
+
+
{{#rooms.length}}
{{#rooms}}
diff --git a/testapp/src/controllers/homeController.ts b/testapp/src/controllers/homeController.ts
index a748249..5719471 100644
--- a/testapp/src/controllers/homeController.ts
+++ b/testapp/src/controllers/homeController.ts
@@ -5,6 +5,10 @@ import {
deleteRoom,
deleteAllRooms,
} from '../services/roomService';
+import {
+ deleteAllRecordings,
+ getAllRecordings,
+} from '../services/recordingService';
export const getHome = async (req: Request, res: Response) => {
try {
@@ -61,6 +65,7 @@ export const deleteAllRoomsCtrl = async (_req: Request, res: Response) => {
return;
}
const roomIds = allRooms.rooms.map((room) => room.roomId);
+ console.log(`Deleting ${roomIds.length} rooms`, roomIds);
await deleteAllRooms(roomIds);
res.render('index', { rooms: [] });
} catch (error) {
@@ -70,26 +75,50 @@ export const deleteAllRoomsCtrl = async (_req: Request, res: Response) => {
}
};
+export const deleteAllRecordingsCtrl = async (_req: Request, res: Response) => {
+ try {
+ const [{ recordings }, { rooms }] = await Promise.all([
+ getAllRecordings(),
+ getAllRooms(),
+ ]);
+ if (recordings.length === 0) {
+ console.log('No recordings to delete');
+ res.render('index', { rooms });
+ return;
+ }
+ const recordingIds = recordings.map((recording) => recording.recordingId);
+ await deleteAllRecordings(recordingIds);
+ console.log(`Deleted ${recordingIds.length} recordings`);
+ res.render('index', { rooms });
+ } catch (error) {
+ console.error('Error deleting all recordings:', error);
+ res.status(500).send('Internal Server Error ' + JSON.stringify(error));
+ return;
+ }
+};
/**
* Converts flat form data to nested MeetRoomPreferences object
*/
const processFormPreferences = (body: any): any => {
- const preferences = {
- chatPreferences: {
- enabled: body['preferences.chatPreferences.enabled'] === 'on'
- },
- recordingPreferences: {
- enabled: body['preferences.recordingPreferences.enabled'] === 'on',
- // Only include allowAccessTo if recording is enabled
- ...(body['preferences.recordingPreferences.enabled'] === 'on' && {
- allowAccessTo: body['preferences.recordingPreferences.allowAccessTo'] || 'admin-moderator-publisher'
- })
- },
- virtualBackgroundPreferences: {
- enabled: body['preferences.virtualBackgroundPreferences.enabled'] === 'on'
- }
- };
+ const preferences = {
+ chatPreferences: {
+ enabled: body['preferences.chatPreferences.enabled'] === 'on',
+ },
+ recordingPreferences: {
+ enabled: body['preferences.recordingPreferences.enabled'] === 'on',
+ // Only include allowAccessTo if recording is enabled
+ ...(body['preferences.recordingPreferences.enabled'] === 'on' && {
+ allowAccessTo:
+ body['preferences.recordingPreferences.allowAccessTo'] ||
+ 'admin-moderator-publisher',
+ }),
+ },
+ virtualBackgroundPreferences: {
+ enabled:
+ body['preferences.virtualBackgroundPreferences.enabled'] === 'on',
+ },
+ };
- return preferences;
-}
\ No newline at end of file
+ return preferences;
+};
diff --git a/testapp/src/index.ts b/testapp/src/index.ts
index 266de6d..5b6d120 100644
--- a/testapp/src/index.ts
+++ b/testapp/src/index.ts
@@ -7,6 +7,7 @@ import {
postCreateRoom,
deleteRoomCtrl,
deleteAllRoomsCtrl,
+ deleteAllRecordingsCtrl,
} from './controllers/homeController';
import { handleWebhook, joinRoom } from './controllers/roomController';
import { configService } from './services/configService';
@@ -34,6 +35,7 @@ app.get('/room', joinRoom);
app.post('/room', postCreateRoom);
app.post('/room/delete', deleteRoomCtrl);
app.post('/delete-all-rooms', deleteAllRoomsCtrl);
+app.post('/delete-all-recordings', deleteAllRecordingsCtrl);
app.post('/join-room', joinRoom);
app.post('/webhook', (req, res) => {
handleWebhook(req, res, io);
diff --git a/testapp/src/services/recordingService.ts b/testapp/src/services/recordingService.ts
new file mode 100644
index 0000000..ce533b5
--- /dev/null
+++ b/testapp/src/services/recordingService.ts
@@ -0,0 +1,41 @@
+import { del, get } from '../utils/http';
+import { MeetRecordingInfo } from '../../../typings/src/recording.model';
+import { configService } from './configService';
+
+export const getAllRecordings = async (): Promise<{
+ pagination: { isTruncated: boolean; nextPageToken?: string };
+ recordings: MeetRecordingInfo[];
+}> => {
+ const url = `${configService.meetApiUrl}/recordings`;
+
+ let { pagination, recordings } = await get<{
+ pagination: any;
+ recordings: MeetRecordingInfo[];
+ }>(url, {
+ headers: { 'x-api-key': configService.apiKey },
+ });
+
+ while (pagination.isTruncated) {
+ const nextPageUrl = `${url}?nextPageToken=${pagination.nextPageToken}`;
+ const nextPageResult = await get<{
+ pagination: any;
+ recordings: MeetRecordingInfo[];
+ }>(nextPageUrl, {
+ headers: { 'x-api-key': configService.apiKey },
+ });
+ recordings.push(...nextPageResult.recordings);
+ pagination = nextPageResult.pagination;
+ }
+ return { pagination, recordings };
+};
+
+export const deleteAllRecordings = async (
+ recordingIds: string[]
+): Promise => {
+ const url = `${
+ configService.meetApiUrl
+ }/recordings?recordingIds=${recordingIds.join(',')}`;
+ await del(url, {
+ headers: { 'x-api-key': configService.apiKey },
+ });
+};
diff --git a/testapp/src/utils/http.ts b/testapp/src/utils/http.ts
index 00ce20c..8d50109 100644
--- a/testapp/src/utils/http.ts
+++ b/testapp/src/utils/http.ts
@@ -31,7 +31,14 @@ async function request(
const text = await response.text();
throw new Error(`HTTP ${response.status}: ${text}`);
}
- return response.json() as Promise;
+
+ // Handle empty responses (e.g., for DELETE requests)
+ const text = await response.text();
+ if (!text) {
+ return {} as T;
+ }
+
+ return JSON.parse(text) as T;
}
export function get(