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

Commit c180708

Browse files
authored
Revert "Make widgets in video rooms mutable again to de-risk future upgrades" (#8803)
This reverts commit 32f667c.
1 parent 3510f8e commit c180708

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/createRoom.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ export default async function createRoom(opts: IOpts): Promise<string | null> {
132132
events: {
133133
// Allow all users to send video member updates
134134
[VIDEO_CHANNEL_MEMBER]: 0,
135+
// Make widgets immutable, even to admins
136+
"im.vector.modular.widgets": 200,
135137
// Annoyingly, we have to reiterate all the defaults here
136138
[EventType.RoomName]: 50,
137139
[EventType.RoomAvatar]: 50,
@@ -142,6 +144,10 @@ export default async function createRoom(opts: IOpts): Promise<string | null> {
142144
[EventType.RoomServerAcl]: 100,
143145
[EventType.RoomEncryption]: 100,
144146
},
147+
users: {
148+
// Temporarily give ourselves the power to set up a widget
149+
[client.getUserId()]: 200,
150+
},
145151
};
146152
}
147153
}
@@ -264,6 +270,11 @@ export default async function createRoom(opts: IOpts): Promise<string | null> {
264270
if (opts.roomType === RoomType.ElementVideo) {
265271
// Set up video rooms with a Jitsi widget
266272
await addVideoChannel(roomId, createOpts.name);
273+
274+
// Reset our power level back to admin so that the widget becomes immutable
275+
const room = client.getRoom(roomId);
276+
const plEvent = room?.currentState.getStateEvents(EventType.RoomPowerLevels, "");
277+
await client.setPowerLevel(roomId, client.getUserId(), 100, plEvent);
267278
}
268279
}).then(function() {
269280
// NB createRoom doesn't block on the client seeing the echo that the

test/createRoom-test.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,34 @@ describe("createRoom", () => {
3737
setupAsyncStoreWithClient(WidgetStore.instance, client);
3838
jest.spyOn(WidgetUtils, "waitForRoomWidget").mockResolvedValue();
3939

40+
const userId = client.getUserId();
4041
const roomId = await createRoom({ roomType: RoomType.ElementVideo });
42+
4143
const [[{
4244
power_level_content_override: {
43-
events: { [VIDEO_CHANNEL_MEMBER]: videoMemberPower },
45+
users: {
46+
[userId]: userPower,
47+
},
48+
events: {
49+
"im.vector.modular.widgets": widgetPower,
50+
[VIDEO_CHANNEL_MEMBER]: videoMemberPower,
51+
},
4452
},
4553
}]] = mocked(client.createRoom).mock.calls as any; // no good type
4654
const [[widgetRoomId, widgetStateKey]] = mocked(client.sendStateEvent).mock.calls;
4755

48-
// We should have set up the Jitsi widget
56+
// We should have had enough power to be able to set up the Jitsi widget
57+
expect(userPower).toBeGreaterThanOrEqual(widgetPower);
58+
// and should have actually set it up
4959
expect(widgetRoomId).toEqual(roomId);
5060
expect(widgetStateKey).toEqual("im.vector.modular.widgets");
5161

5262
// All members should be able to update their connected devices
5363
expect(videoMemberPower).toEqual(0);
64+
// Jitsi widget should be immutable for admins
65+
expect(widgetPower).toBeGreaterThan(100);
66+
// and we should have been reset back to admin
67+
expect(client.setPowerLevel).toHaveBeenCalledWith(roomId, userId, 100, undefined);
5468
});
5569
});
5670

0 commit comments

Comments
 (0)