44
55use OCA \BigBlueButton \Service \RoomService ;
66use OCA \BigBlueButton \Permission ;
7+ use OCA \BigBlueButton \Db \Room ;
78use OCP \IRequest ;
89use OCP \AppFramework \Http ;
910use OCP \AppFramework \Http \DataResponse ;
@@ -63,13 +64,34 @@ public function create(
6364 string $ name ,
6465 string $ welcome ,
6566 int $ maxParticipants ,
66- bool $ record
67+ bool $ record ,
68+ string $ access
6769 ): DataResponse {
70+ if (!$ this ->permission ->isAllowedToCreateRoom ($ this ->userId )) {
71+ return new DataResponse (null , Http::STATUS_FORBIDDEN );
72+ }
73+
74+ $ restriction = $ this ->permission ->getRestriction ($ this ->userId );
75+
76+ if ($ restriction ->getMaxParticipants () > -1 && ($ maxParticipants > $ restriction ->getMaxParticipants () || $ maxParticipants <= 0 )) {
77+ return new DataResponse ('Max participants limit exceeded. ' , Http::STATUS_BAD_REQUEST );
78+ }
79+
80+ if (!$ restriction ->getAllowRecording () && $ record ) {
81+ return new DataResponse ('Not allowed to enable recordings. ' , Http::STATUS_BAD_REQUEST );
82+ }
83+
84+ $ disabledRoomTypes = \json_decode ($ restriction ->getRoomTypes ());
85+ if (in_array ($ access , $ disabledRoomTypes ) || !in_array ($ access , Room::ACCESS )) {
86+ return new DataResponse ('Access type not allowed. ' , Http::STATUS_BAD_REQUEST );
87+ }
88+
6889 return new DataResponse ($ this ->service ->create (
6990 $ name ,
7091 $ welcome ,
7192 $ maxParticipants ,
7293 $ record ,
94+ $ access ,
7395 $ this ->userId
7496 ));
7597 }
@@ -92,6 +114,21 @@ public function update(
92114 return new DataResponse (null , Http::STATUS_FORBIDDEN );
93115 }
94116
117+ $ restriction = $ this ->permission ->getRestriction ($ this ->userId );
118+
119+ if ($ restriction ->getMaxParticipants () > -1 && $ maxParticipants !== $ room ->getMaxParticipants () && ($ maxParticipants > $ restriction ->getMaxParticipants () || $ maxParticipants <= 0 )) {
120+ return new DataResponse ('Max participants limit exceeded. ' , Http::STATUS_BAD_REQUEST );
121+ }
122+
123+ if (!$ restriction ->getAllowRecording () && $ record !== $ room ->getRecord ()) {
124+ return new DataResponse ('Not allowed to enable recordings. ' , Http::STATUS_BAD_REQUEST );
125+ }
126+
127+ $ disabledRoomTypes = \json_decode ($ restriction ->getRoomTypes ());
128+ if ((in_array ($ access , $ disabledRoomTypes ) && $ access !== $ room ->getAccess ()) || !in_array ($ access , Room::ACCESS )) {
129+ return new DataResponse ('Access type not allowed. ' , Http::STATUS_BAD_REQUEST );
130+ }
131+
95132 return $ this ->handleNotFound (function () use ($ id , $ name , $ welcome , $ maxParticipants , $ record , $ everyoneIsModerator , $ access ) {
96133 return $ this ->service ->update ($ id , $ name , $ welcome , $ maxParticipants , $ record , $ access , $ everyoneIsModerator );
97134 });
0 commit comments