fix: on add course plan to space, set m.space.child power level to 0

This commit is contained in:
ggurdin 2025-12-15 11:59:42 -05:00
parent 8d396ef195
commit 3404577ddf
No known key found for this signature in database
GPG key ID: A01CB41737CBB478

View file

@ -38,6 +38,23 @@ extension CoursePlanRoomExtension on Room {
}
Future<void> addCourseToSpace(String courseId) async {
// Ensure students in course can launch activity rooms
final powerLevels = Map<String, dynamic>.from(
getState(EventTypes.RoomPowerLevels)?.content ?? {},
);
powerLevels['events'] ??= <String, dynamic>{};
final events = Map<String, dynamic>.from(powerLevels['events']);
if (events["m.space.child"] != 0) {
events["m.space.child"] = 0;
powerLevels['events'] = events;
await client.setRoomStateWithKey(
id,
EventTypes.RoomPowerLevels,
'',
powerLevels,
);
}
if (coursePlan?.uuid == courseId) return;
final future = waitForRoomInSync();
await client.setRoomStateWithKey(