Make Jitsi widgets in video rooms immutable (#8244)

* Make Jitsi widgets in video rooms immutable

* Test video room creation
This commit is contained in:
Robin
2022-04-07 07:34:07 -04:00
committed by GitHub
parent e54eb81626
commit 5fbb25c707
4 changed files with 119 additions and 33 deletions

View File

@@ -126,11 +126,14 @@ export default async function createRoom(opts: IOpts): Promise<string | null> {
[RoomCreateTypeField]: opts.roomType,
};
// In video rooms, allow all users to send video member updates
// Video rooms require custom power levels
if (opts.roomType === RoomType.ElementVideo) {
createOpts.power_level_content_override = {
events: {
// Allow all users to send video member updates
[VIDEO_CHANNEL_MEMBER]: 0,
// Make widgets immutable, even to admins
"im.vector.modular.widgets": 200,
// Annoyingly, we have to reiterate all the defaults here
[EventType.RoomName]: 50,
[EventType.RoomAvatar]: 50,
@@ -141,6 +144,10 @@ export default async function createRoom(opts: IOpts): Promise<string | null> {
[EventType.RoomServerAcl]: 100,
[EventType.RoomEncryption]: 100,
},
users: {
// Temporarily give ourselves the power to set up a widget
[client.getUserId()]: 200,
},
};
}
}
@@ -259,10 +266,15 @@ export default async function createRoom(opts: IOpts): Promise<string | null> {
if (opts.parentSpace) {
return SpaceStore.instance.addRoomToSpace(opts.parentSpace, roomId, [client.getDomain()], opts.suggested);
}
}).then(() => {
// Set up video rooms with a Jitsi widget
}).then(async () => {
if (opts.roomType === RoomType.ElementVideo) {
return addVideoChannel(roomId, createOpts.name);
// Set up video rooms with a Jitsi widget
await addVideoChannel(roomId, createOpts.name);
// Reset our power level back to admin so that the widget becomes immutable
const room = client.getRoom(roomId);
const plEvent = room?.currentState.getStateEvents(EventType.RoomPowerLevels, "");
await client.setPowerLevel(roomId, client.getUserId(), 100, plEvent);
}
}).then(function() {
// NB createRoom doesn't block on the client seeing the echo that the