From d993436ed59a0dd99bda4c2b58e8d44807df606c Mon Sep 17 00:00:00 2001 From: Entwicklung Date: Wed, 29 Nov 2023 10:53:46 +0100 Subject: [PATCH] (MINOR) fix Room Topic is empty fix user has wrong permission --- confernceUtils.mjs | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/confernceUtils.mjs b/confernceUtils.mjs index 64782d5..7380153 100644 --- a/confernceUtils.mjs +++ b/confernceUtils.mjs @@ -9,21 +9,13 @@ export class conferenceUtils { } async createConference(roomId) { - try { - var roomDescription = await this.client.getRoomStateEvent(roomId, 'm.room.topic'); - console.log(roomDescription); - roomDescription = roomDescription.topic; + var roomDescription = await this.getRoomTopic(roomId) const escapedBaseUrl = JITSI_ADMIN_URL.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - const regex = new RegExp(escapedBaseUrl + '[^\\s\\n]+'); const match = roomDescription.match(regex); if (match) { return match[0]; } - }catch (e) { - console.log('The Room description was empty'); - } - var hash = md5(roomId); return JITSI_ADMIN_URL + '/m/' + hash; @@ -40,13 +32,8 @@ export class conferenceUtils { } async changeRoomName(roomId) { - var roomDescription =''; - try { - roomDescription = await this.client.getRoomStateEvent(roomId, 'm.room.topic'); - roomDescription = roomDescription.topic; - }catch (e) { + var roomDescription = await this.getRoomTopic(roomId) - } var conferenceUrl = await this.createConference(roomId); if (!roomDescription.includes(conferenceUrl)) { try { @@ -66,5 +53,14 @@ export class conferenceUtils { 'Diese Hilfeseite anzeigen: !hilfe\n\r' ); } + async getRoomTopic(roomId){ + var roomDescription = ''; + try { + roomDescription = await this.client.getRoomStateEvent(roomId, 'm.room.topic'); + roomDescription = roomDescription.topic; + }catch (e) { + } + return roomDescription; + } }