Merge pull request #1 from H2-invent/development
(Minor) fix Room Topic is empty
This commit is contained in:
commit
ce90767eba
2 changed files with 27 additions and 11 deletions
|
@ -9,16 +9,22 @@ export class conferenceUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
async createConference(roomId) {
|
async createConference(roomId) {
|
||||||
var roomDescription = await this.client.getRoomStateEvent(roomId, 'm.room.topic');
|
try {
|
||||||
roomDescription = roomDescription.topic;
|
var roomDescription = await this.client.getRoomStateEvent(roomId, 'm.room.topic');
|
||||||
const escapedBaseUrl = JITSI_ADMIN_URL.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
console.log(roomDescription);
|
||||||
|
roomDescription = roomDescription.topic;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
@ -34,11 +40,21 @@ export class conferenceUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
async changeRoomName(roomId) {
|
async changeRoomName(roomId) {
|
||||||
var roomDescription = await this.client.getRoomStateEvent(roomId, 'm.room.topic');
|
var roomDescription ='';
|
||||||
roomDescription = roomDescription.topic;
|
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)) {
|
||||||
await this.client.sendStateEvent(roomId, 'm.room.topic', '', {'topic': roomDescription + "\n\r" + conferenceUrl})
|
try {
|
||||||
|
await this.client.sendStateEvent(roomId, 'm.room.topic', '', {'topic': roomDescription + "\n\r" + conferenceUrl})
|
||||||
|
}catch (e) {
|
||||||
|
await this.client.sendText(roomId, 'Der Bot benötigt die Berechtigung "Moderator" um das Raumthema ändern zu dürfen.');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {AutojoinRoomsMixin, MatrixClient, RustSdkCryptoStorageProvider, SimpleFsStorageProvider} from "matrix-bot-sdk";
|
import {AutojoinRoomsMixin, MatrixClient, RustSdkCryptoStorageProvider, SimpleFsStorageProvider, LogService, LogLevel} from "matrix-bot-sdk";
|
||||||
|
|
||||||
import {MATRIX_DISPLAYNAME, MATRIX_TOKEN, MATRIX_URL} from './config.mjs'
|
import {MATRIX_DISPLAYNAME, MATRIX_TOKEN, MATRIX_URL} from './config.mjs'
|
||||||
import {conferenceUtils} from './confernceUtils.mjs'
|
import {conferenceUtils} from './confernceUtils.mjs'
|
||||||
|
|
Loading…
Add table
Reference in a new issue