From 53614a8cde049c18d761fb522b3f084a834c7372 Mon Sep 17 00:00:00 2001 From: junjiequan Date: Thu, 3 Oct 2024 14:19:55 +0200 Subject: [PATCH] do not throw if room is not found --- src/controllers/logbook.controller.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/controllers/logbook.controller.ts b/src/controllers/logbook.controller.ts index 4752069..4c77cc2 100644 --- a/src/controllers/logbook.controller.ts +++ b/src/controllers/logbook.controller.ts @@ -141,7 +141,6 @@ export class LogbookController { try { const accessToken = this.tokenServiceManager.getToken(); const filter = this.createSynapseFilter(); - console.log("Fetching messages for all rooms"); const { rooms } = await this.synapseService.fetchAllRoomsMessages( filter, accessToken, @@ -214,9 +213,12 @@ export class LogbookController { name, accessToken, ); + const roomId = (allRooms.rooms.pop() as ChatRoom)?.room_id; - const roomId = (allRooms.rooms.pop() as ChatRoom).room_id; - + if (!roomId) { + console.log(`Room - ${name} do not exist`); + return undefined; + } const defaultFilter: LogbookFilters = { textSearch: "", showBotMessages: true,