2017-10-12 06:17:42 +08:00
|
|
|
import flat from 'flat';
|
2018-12-12 04:37:31 +08:00
|
|
|
import { check, Match } from 'meteor/check';
|
2017-10-12 10:00:28 +08:00
|
|
|
import Meetings from '/imports/api/meetings';
|
2016-10-22 00:27:47 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
|
|
|
|
2019-04-04 01:23:31 +08:00
|
|
|
const getLockSettings = props => {
|
|
|
|
if (props) {
|
|
|
|
// Since we miss a name convention here, we need to translate some properties
|
|
|
|
// key name to fit the rest of the messaging system
|
|
|
|
props = Object.assign(props, {
|
|
|
|
disablePrivChat: props.disablePrivateChat,
|
|
|
|
disablePubChat: props.disablePublicChat,
|
|
|
|
setBy: 'temp',
|
|
|
|
});
|
|
|
|
delete props['disablePrivateChat'];
|
|
|
|
delete props['disablePublicChat'];
|
|
|
|
} else {
|
|
|
|
// Default lock settings props
|
|
|
|
props = {
|
|
|
|
disableCam: false,
|
|
|
|
disableMic: false,
|
|
|
|
disablePrivChat: false,
|
|
|
|
disablePubChat: false,
|
|
|
|
lockOnJoin: true,
|
|
|
|
lockOnJoinConfigurable: false,
|
|
|
|
lockedLayout: false,
|
|
|
|
setBy: 'temp',
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return props;
|
|
|
|
};
|
|
|
|
|
2016-10-22 00:27:47 +08:00
|
|
|
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,
|
2018-05-09 01:44:45 +08:00
|
|
|
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,
|
2018-08-03 22:03:16 +08:00
|
|
|
userInactivityInspectTimerInMinutes: Number,
|
|
|
|
userInactivityThresholdInMinutes: Number,
|
|
|
|
userActivitySignResponseDelayInMinutes: Number,
|
2019-01-24 00:13:03 +08:00
|
|
|
timeRemaining: Number,
|
2017-10-12 06:17:42 +08:00
|
|
|
},
|
|
|
|
welcomeProp: {
|
|
|
|
welcomeMsg: String,
|
|
|
|
modOnlyMessage: String,
|
|
|
|
welcomeMsgTemplate: String,
|
|
|
|
},
|
2018-12-12 04:37:31 +08:00
|
|
|
recordProp: Match.ObjectIncluding({
|
2017-10-12 06:17:42 +08:00
|
|
|
allowStartStopRecording: Boolean,
|
|
|
|
autoStartRecording: Boolean,
|
2019-02-20 06:29:23 +08:00
|
|
|
record: Boolean,
|
2018-12-12 04:37:31 +08:00
|
|
|
}),
|
2017-10-12 06:17:42 +08:00
|
|
|
password: {
|
|
|
|
viewerPass: String,
|
|
|
|
moderatorPass: String,
|
|
|
|
},
|
|
|
|
voiceProp: {
|
|
|
|
voiceConf: String,
|
|
|
|
dialNumber: String,
|
|
|
|
telVoice: String,
|
2017-12-23 04:22:24 +08:00
|
|
|
muteOnStart: Boolean,
|
2017-10-12 06:17:42 +08:00
|
|
|
},
|
|
|
|
screenshareProps: {
|
|
|
|
red5ScreenshareIp: String,
|
|
|
|
red5ScreenshareApp: String,
|
|
|
|
screenshareConf: String,
|
|
|
|
},
|
|
|
|
metadataProp: Object,
|
2019-04-04 01:23:31 +08:00
|
|
|
lockSettingsProps: Match.Any,
|
2017-10-12 06:17:42 +08:00
|
|
|
});
|
2016-10-22 00:27:47 +08:00
|
|
|
|
2019-02-20 06:29:23 +08:00
|
|
|
const newMeeting = meeting;
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2019-04-04 01:23:31 +08:00
|
|
|
newMeeting.lockSettingsProps = getLockSettings(meeting.lockSettingsProps);
|
2018-11-10 06:03:25 +08:00
|
|
|
|
2019-02-23 06:08:44 +08:00
|
|
|
newMeeting.welcomeProp.welcomeMsg = newMeeting.welcomeProp.welcomeMsg.replace(
|
|
|
|
'href="event:',
|
|
|
|
'href="',
|
|
|
|
);
|
|
|
|
|
2019-02-26 01:01:28 +08:00
|
|
|
const insertBlankTarget = (s, i) => `${s.substr(0, i)} target="_blank"${s.substr(i)}`;
|
|
|
|
const linkWithoutTarget = new RegExp('<a href="(.*?)">', 'g');
|
|
|
|
linkWithoutTarget.test(newMeeting.welcomeProp.welcomeMsg);
|
|
|
|
|
|
|
|
if (linkWithoutTarget.lastIndex > 0) {
|
|
|
|
newMeeting.welcomeProp.welcomeMsg = insertBlankTarget(
|
|
|
|
newMeeting.welcomeProp.welcomeMsg,
|
|
|
|
linkWithoutTarget.lastIndex - 1,
|
|
|
|
);
|
|
|
|
}
|
2019-02-20 06:29:23 +08:00
|
|
|
|
2016-10-22 00:27:47 +08:00
|
|
|
const modifier = {
|
2017-10-12 06:17:42 +08:00
|
|
|
$set: Object.assign(
|
|
|
|
{ meetingId },
|
2019-02-20 06:29:23 +08:00
|
|
|
flat(newMeeting, { safe: true }),
|
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) {
|
2017-10-13 03:07:02 +08:00
|
|
|
Logger.info(`Added meeting id=${meetingId}`);
|
2016-10-22 00:27:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (numChanged) {
|
2017-10-13 03:07:02 +08:00
|
|
|
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
|
|
|
}
|