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

68 lines
1.6 KiB
JavaScript
Raw Normal View History

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',
// SHORTCUTS
'shortcuts',
2018-09-20 04:32:17 +08:00
// KURENTO
'enableScreensharing',
'enableVideo',
'enableVideoStats',
'autoShareWebcam',
2018-09-20 04:32:17 +08:00
// WHITEBOARD
'multiUserPenOnly',
'presenterTools',
'multiUserTools',
// SKINNING/THEMMING
'customStyle',
'customStyleUrl',
// LAYOUT
'autoSwapLayout',
'hidePresentation',
// OUTSIDE COMMANDS
'outsideToggleSelfVoice',
'outsideToggleRecording',
2018-09-20 04:32:17 +08:00
];
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;
}