2017-10-12 06:17:42 +08:00
|
|
|
import flat from 'flat';
|
2019-03-20 04:06:13 +08:00
|
|
|
import {
|
|
|
|
check,
|
|
|
|
Match,
|
|
|
|
} from 'meteor/check';
|
2020-07-28 04:33:10 +08:00
|
|
|
import SanitizeHTML from 'sanitize-html';
|
2019-08-22 01:42:37 +08:00
|
|
|
import Meetings, { RecordMeetings } from '/imports/api/meetings';
|
2016-10-22 00:27:47 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2019-05-17 04:11:10 +08:00
|
|
|
import createNote from '/imports/api/note/server/methods/createNote';
|
|
|
|
import createCaptions from '/imports/api/captions/server/methods/createCaptions';
|
2019-10-23 09:26:25 +08:00
|
|
|
import { addAnnotationsStreamer } from '/imports/api/annotations/server/streamer';
|
2019-10-25 04:48:03 +08:00
|
|
|
import { addCursorStreamer } from '/imports/api/cursor/server/streamer';
|
2020-06-13 00:24:11 +08:00
|
|
|
import BannedUsers from '/imports/api/users/server/store/bannedUsers';
|
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,
|
2019-04-10 21:44:34 +08:00
|
|
|
enabled: Boolean,
|
|
|
|
record: Boolean,
|
|
|
|
privateChatEnabled: Boolean,
|
2017-10-12 06:17:42 +08:00
|
|
|
},
|
|
|
|
meetingProp: {
|
|
|
|
intId: String,
|
|
|
|
extId: String,
|
|
|
|
isBreakout: Boolean,
|
|
|
|
name: String,
|
|
|
|
},
|
|
|
|
usersProp: {
|
|
|
|
webcamsOnlyForModerator: Boolean,
|
|
|
|
guestPolicy: String,
|
|
|
|
maxUsers: Number,
|
2019-04-23 23:30:55 +08:00
|
|
|
allowModsToUnmuteUsers: Boolean,
|
2017-10-12 06:17:42 +08:00
|
|
|
},
|
|
|
|
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-10 21:44:34 +08:00
|
|
|
lockSettingsProps: {
|
|
|
|
disableCam: Boolean,
|
|
|
|
disableMic: Boolean,
|
|
|
|
disablePrivateChat: Boolean,
|
|
|
|
disablePublicChat: Boolean,
|
2019-03-29 02:47:11 +08:00
|
|
|
disableNote: Boolean,
|
2019-08-10 07:45:26 +08:00
|
|
|
hideUserList: Boolean,
|
2019-04-10 21:44:34 +08:00
|
|
|
lockOnJoin: Boolean,
|
|
|
|
lockOnJoinConfigurable: Boolean,
|
|
|
|
lockedLayout: Boolean,
|
|
|
|
},
|
2017-10-12 06:17:42 +08:00
|
|
|
});
|
2016-10-22 00:27:47 +08:00
|
|
|
|
2019-08-22 01:42:37 +08:00
|
|
|
const {
|
|
|
|
recordProp,
|
|
|
|
...restProps
|
|
|
|
} = meeting;
|
|
|
|
|
|
|
|
const newMeeting = restProps;
|
2019-02-20 06:29:23 +08:00
|
|
|
|
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-10 21:44:34 +08:00
|
|
|
newMeeting.lockSettingsProps = Object.assign(meeting.lockSettingsProps, { setBy: 'temp' });
|
2018-11-10 06:03:25 +08:00
|
|
|
|
2019-04-06 02:33:09 +08:00
|
|
|
const meetingEnded = false;
|
2019-03-20 04:06:13 +08:00
|
|
|
|
2020-07-28 04:33:10 +08:00
|
|
|
let { welcomeMsg } = newMeeting.welcomeProp;
|
2020-07-29 23:31:00 +08:00
|
|
|
const sanitizedWelcomeText = SanitizeHTML(welcomeMsg, {
|
2020-07-30 03:09:15 +08:00
|
|
|
allowedTags: ['b', 'strong', 'i', 'u', 'a', 'br', 'img'],
|
2020-07-28 04:33:10 +08:00
|
|
|
allowedAttributes: {
|
|
|
|
a: ['href', 'name', 'target'],
|
2020-07-30 03:09:15 +08:00
|
|
|
img: ['src'],
|
2020-07-28 04:33:10 +08:00
|
|
|
},
|
|
|
|
});
|
2020-07-29 23:31:00 +08:00
|
|
|
welcomeMsg = sanitizedWelcomeText.replace(
|
2019-02-23 06:08:44 +08:00
|
|
|
'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');
|
2020-07-29 23:31:00 +08:00
|
|
|
linkWithoutTarget.test(welcomeMsg);
|
2019-02-26 01:01:28 +08:00
|
|
|
|
|
|
|
if (linkWithoutTarget.lastIndex > 0) {
|
2020-07-29 23:31:00 +08:00
|
|
|
welcomeMsg = insertBlankTarget(
|
|
|
|
welcomeMsg,
|
2019-02-26 01:01:28 +08:00
|
|
|
linkWithoutTarget.lastIndex - 1,
|
|
|
|
);
|
|
|
|
}
|
2019-02-20 06:29:23 +08:00
|
|
|
|
2020-07-29 23:31:00 +08:00
|
|
|
newMeeting.welcomeProp.welcomeMsg = welcomeMsg;
|
|
|
|
|
|
|
|
const { modOnlyMessage } = newMeeting.welcomeProp;
|
|
|
|
|
|
|
|
const sanitizedModOnlyText = SanitizeHTML(modOnlyMessage, {
|
2020-07-30 03:09:15 +08:00
|
|
|
allowedTags: ['b', 'strong', 'i', 'u', 'a', 'br', 'img'],
|
2020-07-29 23:31:00 +08:00
|
|
|
allowedAttributes: {
|
|
|
|
a: ['href', 'name', 'target'],
|
2020-07-30 03:09:15 +08:00
|
|
|
img: ['src'],
|
2020-07-29 23:31:00 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// note: as of July 2020 `modOnlyMessage` is not published to the client side.
|
|
|
|
// We are sanitizing this data simply to prevent future potential usage
|
|
|
|
// At the moment `modOnlyMessage` is obtained from client side as a response to Enter API
|
|
|
|
newMeeting.welcomeProp.modOnlyMessage = sanitizedModOnlyText;
|
|
|
|
|
2016-10-22 00:27:47 +08:00
|
|
|
const modifier = {
|
2019-03-20 04:06:13 +08:00
|
|
|
$set: Object.assign({
|
|
|
|
meetingId,
|
2019-04-06 02:33:09 +08:00
|
|
|
meetingEnded,
|
2019-05-22 22:44:17 +08:00
|
|
|
publishedPoll: false,
|
2019-03-20 04:06:13 +08:00
|
|
|
}, flat(newMeeting, {
|
|
|
|
safe: true,
|
2019-04-06 02:33:09 +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
|
|
|
}
|
|
|
|
|
2019-03-20 04:06:13 +08:00
|
|
|
const {
|
|
|
|
insertedId,
|
|
|
|
} = numChanged;
|
|
|
|
|
2016-10-22 00:27:47 +08:00
|
|
|
if (insertedId) {
|
2017-10-13 03:07:02 +08:00
|
|
|
Logger.info(`Added meeting id=${meetingId}`);
|
2019-03-30 02:22:52 +08:00
|
|
|
// TODO: Here we call Etherpad API to create this meeting notes. Is there a
|
|
|
|
// better place we can run this post-creation routine?
|
2019-03-29 02:47:11 +08:00
|
|
|
createNote(meetingId);
|
2019-05-17 04:11:10 +08:00
|
|
|
createCaptions(meetingId);
|
2020-06-13 00:24:11 +08:00
|
|
|
BannedUsers.init(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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-08-22 01:42:37 +08:00
|
|
|
const cbRecord = (err, numChanged) => {
|
|
|
|
if (err) {
|
|
|
|
Logger.error(`Adding record prop to collection: ${err}`);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const {
|
|
|
|
insertedId,
|
|
|
|
} = numChanged;
|
|
|
|
|
|
|
|
if (insertedId) {
|
|
|
|
Logger.info(`Added record prop id=${meetingId}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (numChanged) {
|
|
|
|
Logger.info(`Upserted record prop id=${meetingId}`);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
RecordMeetings.upsert(selector, {
|
|
|
|
meetingId,
|
|
|
|
...recordProp,
|
|
|
|
}, cbRecord);
|
|
|
|
|
2019-10-23 09:26:25 +08:00
|
|
|
addAnnotationsStreamer(meetingId);
|
2019-10-25 04:48:03 +08:00
|
|
|
addCursorStreamer(meetingId);
|
2019-10-23 09:26:25 +08:00
|
|
|
|
2016-10-22 00:27:47 +08:00
|
|
|
return Meetings.upsert(selector, modifier, cb);
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|