@@ -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
0 commit comments