2018-09-14 02:09:30 +08:00
|
|
|
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) {
|
2018-09-14 02:09:30 +08:00
|
|
|
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',
|
2019-01-24 00:06:14 +08:00
|
|
|
'lockOnJoin',
|
2018-09-20 04:32:17 +08:00
|
|
|
'askForFeedbackOnLogout',
|
|
|
|
// BRANDING
|
|
|
|
'displayBrandingArea',
|
2018-11-01 02:51:56 +08:00
|
|
|
// SHORTCUTS
|
|
|
|
'shortcuts',
|
2018-09-20 04:32:17 +08:00
|
|
|
// KURENTO
|
|
|
|
'enableScreensharing',
|
|
|
|
'enableVideo',
|
|
|
|
'enableVideoStats',
|
2018-10-25 02:58:59 +08:00
|
|
|
'autoShareWebcam',
|
2019-11-12 01:54:46 +08:00
|
|
|
'bbb_skip_video_preview',
|
2018-09-20 04:32:17 +08:00
|
|
|
// WHITEBOARD
|
2018-09-22 00:42:00 +08:00
|
|
|
'multiUserPenOnly',
|
2018-09-22 03:42:39 +08:00
|
|
|
'presenterTools',
|
|
|
|
'multiUserTools',
|
2018-10-19 04:37:14 +08:00
|
|
|
// SKINNING/THEMMING
|
|
|
|
'customStyle',
|
2018-10-25 02:58:59 +08:00
|
|
|
'customStyleUrl',
|
|
|
|
// LAYOUT
|
2018-10-24 04:44:17 +08:00
|
|
|
'autoSwapLayout',
|
|
|
|
'hidePresentation',
|
2018-11-01 23:03:16 +08:00
|
|
|
// 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-14 02:09:30 +08:00
|
|
|
|
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;
|
2018-09-14 02:09:30 +08:00
|
|
|
}
|