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

95 lines
2.1 KiB
JavaScript
Raw Normal View History

2017-06-29 19:54:19 +08:00
import flat from 'flat';
2017-06-19 21:13:35 +08:00
import { check } from 'meteor/check';
import Meetings from '/imports/api/2.0/meetings';
import Logger from '/imports/startup/server/logger';
import initializeCursor from '/imports/api/1.1/cursor/server/modifiers/initializeCursor';
export default function addMeeting(meeting) {
const meetingId = meeting.meetingProp.intId;
check(meetingId, String);
2017-07-27 01:36:57 +08:00
check(meeting, {
breakoutProps: {
sequence: Number,
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,
},
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,
},
screenshareProps: {
red5ScreenshareIp: String,
red5ScreenshareApp: String,
screenshareConf: String,
},
metadataProp: Object,
});
2017-06-19 21:13:35 +08:00
const selector = {
2017-07-18 21:23:16 +08:00
meetingId,
2017-06-19 21:13:35 +08:00
};
const modifier = {
2017-07-18 21:23:16 +08:00
$set: Object.assign(
{ meetingId },
flat(meeting, { safe: true }),
2017-07-18 21:23:16 +08:00
),
2017-06-19 21:13:35 +08:00
};
const cb = (err, numChanged) => {
if (err) {
2017-06-29 19:54:19 +08:00
Logger.error(`Adding meeting to collection: ${err}`);
return;
2017-06-19 21:13:35 +08:00
}
initializeCursor(meetingId);
const { insertedId } = numChanged;
if (insertedId) {
2017-06-29 19:54:19 +08:00
Logger.info(`Added meeting2x id=${meetingId}`);
2017-06-19 21:13:35 +08:00
}
if (numChanged) {
2017-06-29 19:54:19 +08:00
Logger.info(`Upserted meeting2x id=${meetingId}`);
2017-06-19 21:13:35 +08:00
}
};
return Meetings.upsert(selector, modifier, cb);
}