bigbluebutton-Github/bigbluebutton-html5/imports/api/users-settings/server/methods/addUserSettings.js

54 lines
1.3 KiB
JavaScript
Raw Normal View History

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import addUserSetting from '/imports/api/users-settings/server/modifiers/addUserSetting';
2018-09-18 01:05:39 +08:00
export default function addUserSettings(credentials, meetingId, userId, settings) {
check(meetingId, String);
check(userId, String);
2018-09-20 04:32:17 +08:00
check(settings, [Object]);
const customData = settings.reduce((acc, data) => {
const key = Object.keys(data).shift();
const handledHTML5Parameters = [
'html5recordingbot',
// APP
'autoJoin',
'listenOnlyMode',
'forceListenOnly',
'skipCheck',
2018-09-20 04:34:23 +08:00
'clientTitle',
2018-09-20 04:32:17 +08:00
'lockOnJoin', // NOT IMPLEMENTED YET
'askForFeedbackOnLogout',
// BRANDING
'displayBrandingArea',
// KURENTO
'enableScreensharing',
'enableVideo',
'enableVideoStats',
// WHITEBOARD
];
if (!handledHTML5Parameters.includes(key)) {
return acc;
}
let value = data[key];
try {
value = JSON.parse(value);
} catch (e) {
console.log('error', `Caught: ${e.message}`);
}
return { ...acc, [key]: value };
}, {});
2018-09-18 01:05:39 +08:00
const settingsAdded = [];
2018-09-20 04:32:17 +08:00
Object.entries(customData).forEach((el) => {
2018-09-18 01:05:39 +08:00
const setting = el[0];
const value = el[1];
settingsAdded.push(addUserSetting(meetingId, userId, setting, value));
});
return settingsAdded;
}