Merge pull request #2 from H2-invent/development

(MINOR) fix Room Topic is empty
This commit is contained in:
holema 2023-11-29 10:56:56 +01:00 committed by GitHub
commit 709cc74d46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,21 +9,13 @@ export class conferenceUtils {
} }
async createConference(roomId) { async createConference(roomId) {
try { var roomDescription = await this.getRoomTopic(roomId)
var roomDescription = await this.client.getRoomStateEvent(roomId, 'm.room.topic');
console.log(roomDescription);
roomDescription = roomDescription.topic;
const escapedBaseUrl = JITSI_ADMIN_URL.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); const escapedBaseUrl = JITSI_ADMIN_URL.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const regex = new RegExp(escapedBaseUrl + '[^\\s\\n]+'); const regex = new RegExp(escapedBaseUrl + '[^\\s\\n]+');
const match = roomDescription.match(regex); const match = roomDescription.match(regex);
if (match) { if (match) {
return match[0]; return match[0];
} }
}catch (e) {
console.log('The Room description was empty');
}
var hash = md5(roomId); var hash = md5(roomId);
return JITSI_ADMIN_URL + '/m/' + hash; return JITSI_ADMIN_URL + '/m/' + hash;
@ -40,13 +32,8 @@ export class conferenceUtils {
} }
async changeRoomName(roomId) { async changeRoomName(roomId) {
var roomDescription =''; var roomDescription = await this.getRoomTopic(roomId)
try {
roomDescription = await this.client.getRoomStateEvent(roomId, 'm.room.topic');
roomDescription = roomDescription.topic;
}catch (e) {
}
var conferenceUrl = await this.createConference(roomId); var conferenceUrl = await this.createConference(roomId);
if (!roomDescription.includes(conferenceUrl)) { if (!roomDescription.includes(conferenceUrl)) {
try { try {
@ -66,5 +53,14 @@ export class conferenceUtils {
'Diese Hilfeseite anzeigen: !hilfe\n\r' '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;
}
} }