From af4735c5fac93b598bf84a99d503c9890bd793e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marvin=20=C3=96hlerking?=
<103562092+MarvinOehlerkingCap@users.noreply.github.com>
Date: Fri, 26 Jul 2024 16:28:52 +0200
Subject: [PATCH] N21-2106 Fix oauth school feature (#3492)
---
controllers/administration.js | 31 ++++++++++++++++++-------------
views/administration/school.hbs | 5 +++++
2 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/controllers/administration.js b/controllers/administration.js
index 0791f7c3a3..a97510134b 100644
--- a/controllers/administration.js
+++ b/controllers/administration.js
@@ -1289,7 +1289,7 @@ const getUsersWithoutConsent = async (req, roleName, classId) => {
.map((u) => u._id),
consentStatus: { $in: ['missing', 'parentsAgreed'] },
$limit: batchSize,
- $sort: { 'lastName': 1},
+ $sort: { lastName: 1 },
},
})).data,
);
@@ -2260,6 +2260,8 @@ const schoolUpdateHandler = async (req, res, next) => {
name,
language,
logo_dataUrl,
+ rocketChat,
+ videoconference,
} = req.body;
let logo;
@@ -2270,6 +2272,20 @@ const schoolUpdateHandler = async (req, res, next) => {
};
}
+ const features = new Set(req.body.features);
+
+ if (rocketChat) {
+ features.add('rocketChat');
+ } else {
+ features.delete('rocketChat');
+ }
+
+ if (videoconference) {
+ features.add('videoconference');
+ } else {
+ features.delete('videoconference');
+ }
+
const requestBody = {
name,
language,
@@ -2277,7 +2293,7 @@ const schoolUpdateHandler = async (req, res, next) => {
student: { LERNSTORE_VIEW: false },
teacher: { STUDENT_LIST: false },
},
- features: [],
+ features: Array.from(features),
logo,
};
@@ -2293,17 +2309,6 @@ const schoolUpdateHandler = async (req, res, next) => {
requestBody.permissions.student.LERNSTORE_VIEW = !!req.body.studentlernstorevisibility;
}
- // Update school features
- const possibleSchoolFeatures = [
- 'messenger', 'messengerSchoolRoom', 'messengerStudentRoomCreate', 'rocketChat', 'videoconference',
- ];
-
- for (const feature of possibleSchoolFeatures) {
- if (req.body[feature] === 'true') {
- requestBody.features.push(feature);
- }
- }
-
await api(req, { version: 'v3' }).patch(`/school/${res.locals.currentSchool}`, {
json: requestBody,
});
diff --git a/views/administration/school.hbs b/views/administration/school.hbs
index 8b1dff4828..9a1f72f748 100644
--- a/views/administration/school.hbs
+++ b/views/administration/school.hbs
@@ -344,6 +344,11 @@
{{/each}} {{/if}}
{{> "lib/components/csrfInput"}}
+
+ {{#each @root.school.features}}
+
+ {{/each}}
+