bigbluebutton-Github/bigbluebutton-html5/imports/api/meetings/server/modifiers/changeLockSettings.js
2019-05-08 20:36:36 +00:00

63 lines
1.4 KiB
JavaScript

import Logger from '/imports/startup/server/logger';
import Meetings from '/imports/api/meetings';
import { check } from 'meteor/check';
export default function changeLockSettings(meetingId, payload) {
check(meetingId, String);
check(payload, {
disableCam: Boolean,
disableMic: Boolean,
disablePrivChat: Boolean,
disablePubChat: Boolean,
disableNote: Boolean,
lockedLayout: Boolean,
lockOnJoin: Boolean,
lockOnJoinConfigurable: Boolean,
setBy: Match.Maybe(String),
});
const {
disableCam,
disableMic,
disablePrivChat,
disablePubChat,
lockedLayout,
lockOnJoin,
lockOnJoinConfigurable,
setBy,
} = payload;
const selector = {
meetingId,
};
const modifier = {
$set: {
lockSettingsProps: {
disableCam,
disableMic,
disablePrivateChat: disablePrivChat,
disablePublicChat: disablePubChat,
lockedLayout,
lockOnJoin,
lockOnJoinConfigurable,
setBy,
},
},
};
const cb = (err, numChanged) => {
if (err) {
return Logger.error(`Changing meeting={${meetingId}} lock settings: ${err}`);
}
if (!numChanged) {
return Logger.info(`meeting={${meetingId}} lock settings were not updated`);
}
return Logger.info(`Changed meeting={${meetingId}} updated lock settings`);
};
return Meetings.upsert(selector, modifier, cb);
}