Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Make Jitsi widgets in video rooms immutable #8244

Merged
merged 2 commits into from
Apr 7, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/createRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
},
t3chguy marked this conversation as resolved.
Show resolved Hide resolved
};
}
}
Expand Down Expand Up @@ -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
Expand Down