bigbluebutton-Github/bigbluebutton-html5/imports/api/meetings/server/modifiers/addMeeting.js

107 lines
2.5 KiB
JavaScript
Raw Normal View History

2017-10-12 06:17:42 +08:00
import flat from 'flat';
2016-10-22 00:27:47 +08:00
import { check } from 'meteor/check';
import Meetings from '/imports/api/meetings';
2016-10-22 00:27:47 +08:00
import Logger from '/imports/startup/server/logger';
export default function addMeeting(meeting) {
2017-10-12 06:17:42 +08:00
const meetingId = meeting.meetingProp.intId;
2016-10-22 00:27:47 +08:00
check(meetingId, String);
2017-10-12 06:17:42 +08:00
check(meeting, {
breakoutProps: {
sequence: Number,
freeJoin: Boolean,
2017-10-12 06:17:42 +08:00
breakoutRooms: Array,
parentId: String,
},
meetingProp: {
intId: String,
extId: String,
isBreakout: Boolean,
name: String,
},
usersProp: {
webcamsOnlyForModerator: Boolean,
guestPolicy: String,
maxUsers: Number,
},
durationProps: {
createdTime: Number,
duration: Number,
createdDate: String,
maxInactivityTimeoutMinutes: Number,
warnMinutesBeforeMax: Number,
meetingExpireIfNoUserJoinedInMinutes: Number,
meetingExpireWhenLastUserLeftInMinutes: Number,
userInactivityInspectTimerInMinutes: Number,
userInactivityThresholdInMinutes: Number,
userActivitySignResponseDelayInMinutes: Number,
2017-10-12 06:17:42 +08:00
},
welcomeProp: {
welcomeMsg: String,
modOnlyMessage: String,
welcomeMsgTemplate: String,
},
recordProp: {
allowStartStopRecording: Boolean,
autoStartRecording: Boolean,
record: Boolean,
},
password: {
viewerPass: String,
moderatorPass: String,
},
voiceProp: {
voiceConf: String,
dialNumber: String,
telVoice: String,
muteOnStart: Boolean,
2017-10-12 06:17:42 +08:00
},
screenshareProps: {
red5ScreenshareIp: String,
red5ScreenshareApp: String,
screenshareConf: String,
},
metadataProp: Object,
});
2016-10-22 00:27:47 +08:00
const selector = {
2016-10-24 19:20:30 +08:00
meetingId,
2016-10-22 00:27:47 +08:00
};
const lockSettingsProp = {
disableCam: false,
disableMic: false,
disablePrivChat: false,
disablePubChat: false,
lockOnJoin: true,
lockOnJoinConfigurable: false,
lockedLayout: false,
};
2016-10-22 00:27:47 +08:00
const modifier = {
2017-10-12 06:17:42 +08:00
$set: Object.assign(
{ meetingId },
flat(meeting, { safe: true }),
{ lockSettingsProp },
2017-10-12 06:17:42 +08:00
),
2016-10-22 00:27:47 +08:00
};
const cb = (err, numChanged) => {
if (err) {
2017-10-12 06:17:42 +08:00
Logger.error(`Adding meeting to collection: ${err}`);
return;
2016-10-22 00:27:47 +08:00
}
const { insertedId } = numChanged;
if (insertedId) {
Logger.info(`Added meeting id=${meetingId}`);
2016-10-22 00:27:47 +08:00
}
if (numChanged) {
Logger.info(`Upserted meeting id=${meetingId}`);
2016-10-22 00:27:47 +08:00
}
};
return Meetings.upsert(selector, modifier, cb);
2017-06-03 03:25:02 +08:00
}