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,7 +9,9 @@ export class conferenceUtils {
|
|||
}
|
||||
|
||||
async createConference(roomId) {
|
||||
try {
|
||||
var roomDescription = await this.client.getRoomStateEvent(roomId, 'm.room.topic');
|
||||
console.log(roomDescription);
|
||||
roomDescription = roomDescription.topic;
|
||||
const escapedBaseUrl = JITSI_ADMIN_URL.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
|
||||
|
@ -18,6 +20,10 @@ export class conferenceUtils {
|
|||
if (match) {
|
||||
return match[0];
|
||||
}
|
||||
}catch (e) {
|
||||
console.log('The Room description was empty');
|
||||
}
|
||||
|
||||
|
||||
var hash = md5(roomId);
|
||||
return JITSI_ADMIN_URL + '/m/' + hash;
|
||||
|
@ -34,11 +40,21 @@ export class conferenceUtils {
|
|||
}
|
||||
|
||||
async changeRoomName(roomId) {
|
||||
var roomDescription = await this.client.getRoomStateEvent(roomId, 'm.room.topic');
|
||||
var roomDescription ='';
|
||||
try {
|
||||
roomDescription = await this.client.getRoomStateEvent(roomId, 'm.room.topic');
|
||||
roomDescription = roomDescription.topic;
|
||||
}catch (e) {
|
||||
|
||||
}
|
||||
var conferenceUrl = await this.createConference(roomId);
|
||||
if (!roomDescription.includes(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 {conferenceUtils} from './confernceUtils.mjs'
|
||||
|
|
Loading…
Add table
Reference in a new issue