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

109 lines
3.1 KiB
JavaScript
Raw Normal View History

import { check } from 'meteor/check';
import addUserSetting from '/imports/api/users-settings/server/modifiers/addUserSetting';
import logger from '/imports/startup/server/logger';
const oldParameters = {
autoJoin: 'bbb_auto_join_audio',
listenOnlyMode: 'bbb_listen_only_mode',
skipCheck: 'bbb_skip_check_audio',
shortcuts: 'bbb_shortcuts',
autoShareWebcam: 'bbb_auto_share_webcam',
customStyle: 'bbb_custom_style',
autoSwapLayout: 'bbb_auto_swap_layout',
hidePresentation: 'bbb_hide_presentation',
outsideToggleSelfVoice: 'bbb_outside_toggle_self_voice',
outsideToggleRecording: 'bbb_outside_toggle_recording',
forceListenOnly: 'bbb_force_listen_only',
clientTitle: 'bbb_client_title',
askForFeedbackOnLogout: 'bbb_ask_for_feedback_on_logout',
displayBrandingArea: 'bbb_display_branding_area',
enableScreensharing: 'bbb_enable_screen_sharing',
enableVideo: 'bbb_enable_video',
enableVideoStats: 'bbb_enable_video_stats',
multiUserPenOnly: 'bbb_multi_user_pen_only',
presenterTools: 'bbb_presenter_tools',
multiUserTools: 'bbb_multi_user_tools',
customStyleUrl: 'bbb_custom_style_url',
};
const oldParametersKeys = Object.keys(oldParameters);
const currentParameters = [
2019-07-18 21:22:39 +08:00
// APP
'bbb_auto_join_audio',
'bbb_listen_only_mode',
'bbb_force_listen_only',
'bbb_skip_check_audio',
'bbb_client_title',
'bbb_ask_for_feedback_on_logout',
2019-07-18 21:22:39 +08:00
// BRANDING
'bbb_display_branding_area',
2019-07-18 21:22:39 +08:00
// SHORTCUTS
'bbb_shortcuts',
2019-07-18 21:22:39 +08:00
// KURENTO
'bbb_enable_screen_sharing',
'bbb_enable_video',
'bbb_enable_video_stats',
'bbb_auto_share_webcam',
2019-07-18 21:22:39 +08:00
// WHITEBOARD
'bbb_multi_user_pen_only',
'bbb_presenter_tools',
'bbb_multi_user_tools',
2019-07-18 21:22:39 +08:00
// SKINNING/THEMMING
'bbb_custom_style',
'bbb_custom_style_url',
2019-07-18 21:22:39 +08:00
// LAYOUT
'bbb_auto_swap_layout',
'bbb_hide_presentation',
// OUTSIDE COMMANDS
2019-07-18 21:22:39 +08:00
'bbb_outside_toggle_self_voice',
'bbb_outside_toggle_recording',
2019-07-18 21:22:39 +08:00
];
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]);
let parameters = {};
settings.forEach((el) => {
const settingKey = Object.keys(el).shift();
2019-07-27 01:55:40 +08:00
if (currentParameters.includes(settingKey)) {
if (!Object.keys(parameters).includes(settingKey)) {
parameters = {
[settingKey]: el[settingKey],
...parameters,
};
} else {
parameters[settingKey] = el[settingKey];
2019-07-18 21:22:39 +08:00
}
return;
}
2019-07-18 21:22:39 +08:00
if (oldParametersKeys.includes(settingKey)) {
const matchingNewKey = oldParameters[settingKey];
const matchingNewKeyValue = el[settingKey];
2018-09-20 04:32:17 +08:00
if (!Object.keys(parameters).includes(matchingNewKey)) {
parameters = {
[matchingNewKey]: matchingNewKeyValue,
...parameters,
};
2019-07-18 21:22:39 +08:00
}
return;
}
logger.warn(`Parameter ${settingKey} not handled`);
});
2018-09-18 01:05:39 +08:00
const settingsAdded = [];
Object.entries(parameters).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;
}