2017-07-14 20:32:15 +08:00
|
|
|
import { check } from 'meteor/check';
|
2019-12-19 05:40:04 +08:00
|
|
|
import Meetings from '/imports/api/meetings';
|
2019-12-20 05:13:21 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-07-27 23:27:06 +08:00
|
|
|
import addScreenshare from '../modifiers/addScreenshare';
|
2019-12-19 05:40:04 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2019-12-20 05:13:21 +08:00
|
|
|
import stopWatchingExternalVideo from '/imports/api/external-videos/server/methods/stopWatchingExternalVideo';
|
2017-07-14 20:32:15 +08:00
|
|
|
|
2017-09-09 01:00:00 +08:00
|
|
|
export default function handleScreenshareStarted({ body }, meetingId) {
|
2017-07-14 20:32:15 +08:00
|
|
|
check(meetingId, String);
|
2017-07-14 22:18:46 +08:00
|
|
|
check(body, Object);
|
|
|
|
|
2019-12-19 05:40:04 +08:00
|
|
|
const meeting = Meetings.findOne({ meetingId });
|
2019-12-20 05:13:21 +08:00
|
|
|
const presenter = Users.findOne({ meetingId, presenter: true });
|
|
|
|
const presenterId = presenter && presenter.userId ? presenter.userId : 'system-screenshare-starting';
|
2019-12-19 05:40:04 +08:00
|
|
|
if (meeting && meeting.externalVideoUrl) {
|
|
|
|
Logger.info(`ScreenshareStarted: There is external video being shared. Stopping it due to presenter change, ${meeting.externalVideoUrl}`);
|
2019-12-20 05:13:21 +08:00
|
|
|
stopWatchingExternalVideo({ meetingId, requesterUserId: presenterId });
|
2019-12-19 05:40:04 +08:00
|
|
|
}
|
2017-07-27 23:27:06 +08:00
|
|
|
return addScreenshare(meetingId, body);
|
2017-07-14 20:32:15 +08:00
|
|
|
}
|