let server handle parameters

This commit is contained in:
João Francisco Siebel 2018-09-19 17:32:17 -03:00
parent e750ceb0a1
commit bb58a3fde6
2 changed files with 38 additions and 40 deletions

View File

@ -5,11 +5,45 @@ import addUserSetting from '/imports/api/users-settings/server/modifiers/addUser
export default function addUserSettings(credentials, meetingId, userId, settings) {
check(meetingId, String);
check(userId, String);
check(settings, Object);
check(settings, [Object]);
const customData = settings.reduce((acc, data) => {
const key = Object.keys(data).shift();
const handledHTML5Parameters = [
'html5recordingbot',
// APP
'autoJoin',
'listenOnlyMode',
'forceListenOnly',
'skipCheck',
// 'clientTitle',
'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 };
}, {});
const settingsAdded = [];
Object.entries(settings).forEach((el) => {
Object.entries(customData).forEach((el) => {
const setting = el[0];
const value = el[1];
settingsAdded.push(addUserSetting(meetingId, userId, setting, value));

View File

@ -60,44 +60,8 @@ export function joinRouteHandler(nextState, replace, callback) {
return { ...acc, [key]: value };
}, {}) : {};
const customData = customdata.length
? customdata.reduce((acc, data) => {
const key = Object.keys(data).shift();
const handledHTML5Parameters = [
'html5recordingbot',
// APP
'autoJoin',
'listenOnlyMode',
'forceListenOnly',
'skipCheck',
'clientTitle',
'lockOnJoin', // NOT IMPLEMENTED YET
'askForFeedbackOnLogout',
// BRANDING
'displayBrandingArea',
// KURENTO
'enableScreensharing',
'enableVideo',
'enableVideoStats',
// WHITEBOARD
];
if (handledHTML5Parameters.indexOf(key) === -1) {
return acc;
}
let value = data[key];
try {
value = JSON.parse(value);
} catch (e) {
log('error', `Caught: ${e.message}`);
}
return { ...acc, [key]: value };
}, {}) : {};
if (Object.keys(customData).length > 0) {
makeCall('addUserSettings', meetingID, internalUserID, customData);
if (customdata.length) {
makeCall('addUserSettings', meetingID, internalUserID, customdata);
}
SessionStorage.setItem(METADATA_KEY, metakeys);