Merge pull request #4848 from pangeachat/4839-on-add-course-plan-to-space-set-mspacechild-power-level-to-0

fix: on add course plan to space, set m.space.child power level to 0
This commit is contained in:
ggurdin 2025-12-15 12:00:12 -05:00 committed by GitHub
commit 7b09ae8969
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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(