2018-09-14 02:09:30 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import addUserSetting from '/imports/api/users-settings/server/modifiers/addUserSetting';
|
2019-07-25 01:04:46 +08:00
|
|
|
import logger from '/imports/startup/server/logger';
|
2020-04-29 12:41:16 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
2018-09-14 02:09:30 +08:00
|
|
|
|
2019-07-22 22:28:13 +08:00
|
|
|
const oldParameters = {
|
2019-11-07 04:53:24 +08:00
|
|
|
askForFeedbackOnLogout: 'bbb_ask_for_feedback_on_logout',
|
2019-07-22 22:28:13 +08:00
|
|
|
autoJoin: 'bbb_auto_join_audio',
|
|
|
|
autoShareWebcam: 'bbb_auto_share_webcam',
|
2019-07-25 01:04:46 +08:00
|
|
|
clientTitle: 'bbb_client_title',
|
2019-11-07 04:53:24 +08:00
|
|
|
customStyle: 'bbb_custom_style',
|
|
|
|
customStyleUrl: 'bbb_custom_style_url',
|
2019-07-25 01:04:46 +08:00
|
|
|
displayBrandingArea: 'bbb_display_branding_area',
|
|
|
|
enableVideo: 'bbb_enable_video',
|
2019-11-07 04:53:24 +08:00
|
|
|
forceListenOnly: 'bbb_force_listen_only',
|
2023-02-18 01:59:39 +08:00
|
|
|
hidePresentationOnJoin: 'bbb_hide_presentation',
|
2019-11-07 04:53:24 +08:00
|
|
|
listenOnlyMode: 'bbb_listen_only_mode',
|
2019-07-25 01:04:46 +08:00
|
|
|
multiUserPenOnly: 'bbb_multi_user_pen_only',
|
|
|
|
multiUserTools: 'bbb_multi_user_tools',
|
2019-11-07 04:53:24 +08:00
|
|
|
presenterTools: 'bbb_presenter_tools',
|
|
|
|
shortcuts: 'bbb_shortcuts',
|
|
|
|
skipCheck: 'bbb_skip_check_audio',
|
2019-07-22 22:28:13 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const oldParametersKeys = Object.keys(oldParameters);
|
|
|
|
|
|
|
|
const currentParameters = [
|
2019-07-18 21:22:39 +08:00
|
|
|
// APP
|
2019-11-07 04:53:24 +08:00
|
|
|
'bbb_ask_for_feedback_on_logout',
|
2020-09-09 02:54:08 +08:00
|
|
|
'bbb_override_default_locale',
|
2019-07-22 22:28:13 +08:00
|
|
|
'bbb_auto_join_audio',
|
2019-11-07 04:53:24 +08:00
|
|
|
'bbb_client_title',
|
2019-07-25 01:04:46 +08:00
|
|
|
'bbb_force_listen_only',
|
2019-11-07 04:53:24 +08:00
|
|
|
'bbb_listen_only_mode',
|
2019-07-22 22:28:13 +08:00
|
|
|
'bbb_skip_check_audio',
|
2021-02-05 02:42:31 +08:00
|
|
|
'bbb_skip_check_audio_on_first_join',
|
2019-07-18 21:22:39 +08:00
|
|
|
// BRANDING
|
2019-07-25 01:04:46 +08:00
|
|
|
'bbb_display_branding_area',
|
2019-07-18 21:22:39 +08:00
|
|
|
// SHORTCUTS
|
2019-07-22 22:28:13 +08:00
|
|
|
'bbb_shortcuts',
|
2019-07-18 21:22:39 +08:00
|
|
|
// KURENTO
|
2019-11-07 04:53:24 +08:00
|
|
|
'bbb_auto_share_webcam',
|
2019-11-08 04:55:04 +08:00
|
|
|
'bbb_preferred_camera_profile',
|
2019-07-25 01:04:46 +08:00
|
|
|
'bbb_enable_video',
|
2020-08-22 06:10:25 +08:00
|
|
|
'bbb_record_video',
|
2019-11-12 02:17:40 +08:00
|
|
|
'bbb_skip_video_preview',
|
2021-02-02 02:47:05 +08:00
|
|
|
'bbb_skip_video_preview_on_first_join',
|
2020-06-15 03:13:47 +08:00
|
|
|
'bbb_mirror_own_webcam',
|
2020-05-12 20:58:14 +08:00
|
|
|
// PRESENTATION
|
|
|
|
'bbb_force_restore_presentation_on_new_events',
|
2019-07-18 21:22:39 +08:00
|
|
|
// WHITEBOARD
|
2019-07-25 01:04:46 +08:00
|
|
|
'bbb_multi_user_pen_only',
|
|
|
|
'bbb_presenter_tools',
|
|
|
|
'bbb_multi_user_tools',
|
2019-07-18 21:22:39 +08:00
|
|
|
// SKINNING/THEMMING
|
2019-07-22 22:28:13 +08:00
|
|
|
'bbb_custom_style',
|
2019-07-25 01:04:46 +08:00
|
|
|
'bbb_custom_style_url',
|
2019-07-18 21:22:39 +08:00
|
|
|
// LAYOUT
|
2023-02-18 01:59:39 +08:00
|
|
|
'bbb_hide_presentation_on_join',
|
2020-01-30 05:40:00 +08:00
|
|
|
'bbb_show_participants_on_login',
|
2020-05-24 04:28:56 +08:00
|
|
|
'bbb_show_public_chat_on_login',
|
2021-10-20 03:20:31 +08:00
|
|
|
'bbb_hide_actions_bar',
|
2021-10-20 04:43:33 +08:00
|
|
|
'bbb_hide_nav_bar',
|
2021-12-16 03:00:29 +08:00
|
|
|
'bbb_change_layout',
|
2019-07-18 21:22:39 +08:00
|
|
|
];
|
|
|
|
|
2019-08-03 02:38:38 +08:00
|
|
|
function valueParser(val) {
|
|
|
|
try {
|
2020-09-08 22:29:05 +08:00
|
|
|
const parsedValue = JSON.parse(val.toLowerCase().trim());
|
2019-08-03 02:38:38 +08:00
|
|
|
return parsedValue;
|
|
|
|
} catch (error) {
|
2020-08-11 03:54:58 +08:00
|
|
|
logger.warn(`addUserSettings:Parameter ${val} could not be parsed (was not json)`);
|
2019-08-03 02:38:38 +08:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
2018-09-14 02:09:30 +08:00
|
|
|
|
2020-04-29 12:41:16 +08:00
|
|
|
export default function addUserSettings(settings) {
|
2021-05-06 01:22:12 +08:00
|
|
|
try {
|
|
|
|
check(settings, [Object]);
|
2018-09-20 04:32:17 +08:00
|
|
|
|
2021-05-06 01:22:12 +08:00
|
|
|
const { meetingId, requesterUserId: userId } = extractCredentials(this.userId);
|
2020-04-29 12:41:16 +08:00
|
|
|
|
2021-05-06 01:22:12 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
2021-03-17 00:15:41 +08:00
|
|
|
|
2021-05-06 01:22:12 +08:00
|
|
|
let parameters = {};
|
2018-09-20 04:32:17 +08:00
|
|
|
|
2021-05-06 01:22:12 +08:00
|
|
|
settings.forEach((el) => {
|
|
|
|
const settingKey = Object.keys(el).shift();
|
|
|
|
const normalizedKey = settingKey.trim();
|
2019-07-27 01:55:40 +08:00
|
|
|
|
2021-05-06 01:22:12 +08:00
|
|
|
if (currentParameters.includes(normalizedKey)) {
|
|
|
|
if (!Object.keys(parameters).includes(normalizedKey)) {
|
|
|
|
parameters = {
|
|
|
|
[normalizedKey]: valueParser(el[settingKey]),
|
|
|
|
...parameters,
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
parameters[normalizedKey] = el[settingKey];
|
|
|
|
}
|
|
|
|
return;
|
2019-07-18 21:22:39 +08:00
|
|
|
}
|
2018-09-20 04:32:17 +08:00
|
|
|
|
2021-05-06 01:22:12 +08:00
|
|
|
if (oldParametersKeys.includes(normalizedKey)) {
|
|
|
|
const matchingNewKey = oldParameters[normalizedKey];
|
|
|
|
if (!Object.keys(parameters).includes(matchingNewKey)) {
|
|
|
|
parameters = {
|
|
|
|
[matchingNewKey]: valueParser(el[settingKey]),
|
|
|
|
...parameters,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return;
|
2019-07-18 21:22:39 +08:00
|
|
|
}
|
2018-09-14 02:09:30 +08:00
|
|
|
|
2021-05-06 01:22:12 +08:00
|
|
|
logger.warn(`Parameter ${normalizedKey} not handled`);
|
|
|
|
});
|
2018-09-18 01:05:39 +08:00
|
|
|
|
2021-05-06 01:22:12 +08:00
|
|
|
const settingsAdded = [];
|
|
|
|
Object.entries(parameters).forEach((el) => {
|
|
|
|
const setting = el[0];
|
|
|
|
const value = el[1];
|
|
|
|
settingsAdded.push(addUserSetting(meetingId, userId, setting, value));
|
|
|
|
});
|
2018-09-18 01:05:39 +08:00
|
|
|
|
2021-05-06 01:22:12 +08:00
|
|
|
return settingsAdded;
|
|
|
|
} catch (err) {
|
|
|
|
logger.error(`Exception while invoking method addUserSettings ${err.stack}`);
|
|
|
|
}
|
2018-09-14 02:09:30 +08:00
|
|
|
}
|