@@ -3,9 +3,11 @@ import 'dart:developer';
3
3
4
4
import 'package:collection/collection.dart' ;
5
5
import 'package:fluffychat/pangea/constants/local.key.dart' ;
6
+ import 'package:fluffychat/pangea/constants/pangea_event_types.dart' ;
6
7
import 'package:fluffychat/pangea/controllers/pangea_controller.dart' ;
7
8
import 'package:fluffychat/pangea/extensions/client_extension.dart' ;
8
9
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart' ;
10
+ import 'package:fluffychat/pangea/models/class_model.dart' ;
9
11
import 'package:fluffychat/pangea/utils/class_code.dart' ;
10
12
import 'package:fluffychat/pangea/utils/error_handler.dart' ;
11
13
import 'package:flutter/foundation.dart' ;
@@ -156,4 +158,24 @@ class ClassController extends BaseController {
156
158
// BE - check class code and if class code is correct, invite student to room
157
159
// FE - look for invite from room and automatically accept
158
160
}
161
+
162
+ Future <void > addMissingRoomRules (String ? roomId) async {
163
+ if (roomId == null ) return ;
164
+ final Room ? room = _pangeaController.matrixState.client.getRoomById (roomId);
165
+ if (room == null ) return ;
166
+
167
+ if (room.classSettings != null && room.pangeaRoomRules == null ) {
168
+ try {
169
+ await _pangeaController.matrixState.client.setRoomStateWithKey (
170
+ roomId,
171
+ PangeaEventTypes .rules,
172
+ '' ,
173
+ PangeaRoomRules ().toJson (),
174
+ );
175
+ } catch (err, stack) {
176
+ debugger (when : kDebugMode);
177
+ ErrorHandler .logError (e: err, s: stack);
178
+ }
179
+ }
180
+ }
159
181
}
0 commit comments